Strict mode in functions check for static modules.

This commit is contained in:
Stephen Chung
2022-06-09 17:59:28 +08:00
parent 285bf23dfa
commit dcaac20eb9
5 changed files with 50 additions and 52 deletions

View File

@@ -32,13 +32,17 @@ impl Engine {
if let Some(index) = index {
let offset = global.num_imports() - index.get();
Some(global.get_shared_import(offset).unwrap())
} else {
global
.find_import(root)
.map(|n| global.get_shared_import(n).unwrap())
.or_else(|| self.global_sub_modules.get(root).cloned())
if let m @ Some(_) = global.get_shared_import(offset) {
return m;
}
}
// Do a text-match search if the index doesn't work
global.find_import(root).map_or_else(
|| self.global_sub_modules.get(root).cloned(),
|offset| global.get_shared_import(offset),
)
}
/// Search for a variable within the scope or within imports,