Fix bug with using self-contained AST with call_fn.

This commit is contained in:
Stephen Chung
2022-05-05 21:34:15 +08:00
parent 2a57bd9d25
commit b23d64bec0
3 changed files with 27 additions and 3 deletions

View File

@@ -244,6 +244,12 @@ impl Engine {
let orig_scope_len = scope.len();
#[cfg(not(feature = "no_module"))]
let orig_embedded_module_resolver = std::mem::replace(
&mut global.embedded_module_resolver,
ast.resolver().cloned(),
);
if eval_ast && !statements.is_empty() {
self.eval_global_statements(scope, global, caches, statements, &[ast.as_ref()], 0)?;
@@ -278,6 +284,11 @@ impl Engine {
0,
)?;
#[cfg(not(feature = "no_module"))]
{
global.embedded_module_resolver = orig_embedded_module_resolver;
}
#[cfg(feature = "debugging")]
if self.debugger.is_some() {
global.debugger.status = crate::eval::DebuggerStatus::Terminate;