Fix bug in try block.

This commit is contained in:
Stephen Chung
2022-01-24 08:34:21 +08:00
parent 922931f51d
commit 8d34ffb9f5
4 changed files with 83 additions and 4 deletions

View File

@@ -35,7 +35,7 @@ impl Engine {
state.scope_level += 1;
}
let mut result = Dynamic::UNIT;
let mut result = Ok(Dynamic::UNIT);
for stmt in statements {
let _mods_len = global.num_imports();
@@ -49,7 +49,11 @@ impl Engine {
stmt,
restore_orig_state,
level,
)?;
);
if result.is_err() {
break;
}
#[cfg(not(feature = "no_module"))]
if matches!(stmt, Stmt::Import(_, _, _)) {
@@ -89,7 +93,7 @@ impl Engine {
state.always_search_scope = orig_always_search_scope;
}
Ok(result)
result
}
/// Evaluate an op-assignment statement.