Handle shared for loop variable.

This commit is contained in:
Stephen Chung 2020-08-03 23:11:38 +08:00
parent abe74e7f44
commit 3b6d35368f

View File

@ -1701,7 +1701,15 @@ impl Engine {
state.scope_level += 1; state.scope_level += 1;
for loop_var in func(iter_type) { for loop_var in func(iter_type) {
*scope.get_mut(index).0 = loop_var; let for_var = scope.get_mut(index).0;
let value = loop_var.clone_inner_data().unwrap();
if cfg!(not(feature = "no_closure")) && for_var.is_shared() {
*for_var.write_lock().unwrap() = value;
} else {
*for_var = value;
}
self.inc_operations(state) self.inc_operations(state)
.map_err(|err| err.new_position(stmt.position()))?; .map_err(|err| err.new_position(stmt.position()))?;