Fix for loop operations.

This commit is contained in:
Stephen Chung 2023-03-23 09:38:54 +08:00
parent 3c7cd8e278
commit 3d06ddc6e2

View File

@ -686,6 +686,11 @@ impl Engine {
let mut result = Dynamic::UNIT;
if body.is_empty() {
for _ in iter_func(iter_obj) {
self.track_operation(global, body.position())?;
}
} else {
for (x, iter_value) in iter_func(iter_obj).enumerate() {
// Increment counter
if let Some(counter_index) = counter_index {
@ -715,10 +720,6 @@ impl Engine {
*scope.get_mut_by_index(index).write_lock().unwrap() = value;
// Run block
if body.is_empty() {
continue;
}
let this_ptr = this_ptr.as_deref_mut();
match self.eval_stmt_block(global, caches, scope, this_ptr, body, true) {
@ -733,6 +734,7 @@ impl Engine {
},
}
}
}
Ok(result)
}