diff --git a/src/protocol/eval/executor.rs b/src/protocol/eval/executor.rs index 75c41c08a68920931792d388ed51c4c5cdb16cb6..fe43edfd8207faf5e777a0eb40d607093c617812 100644 --- a/src/protocol/eval/executor.rs +++ b/src/protocol/eval/executor.rs @@ -825,8 +825,13 @@ impl Prompt { Statement::Local(stmt) => { match stmt { LocalStatement::Memory(stmt) => { - let variable = &heap[stmt.variable]; - self.store.write(ValueId::Stack(variable.unique_id_in_scope as u32), Value::Unassigned); + if cfg!(debug_assertions) { + let variable = &heap[stmt.variable]; + debug_assert!(match self.store.read_ref(ValueId::Stack(variable.unique_id_in_scope as u32)) { + Value::Unassigned => false, + _ => true, + }); + } cur_frame.position = stmt.next; Ok(EvalContinuation::Stepping) @@ -1049,6 +1054,16 @@ impl Prompt { let stmt = &heap[cur_frame.position]; match stmt { + Statement::Local(stmt) => { + if let LocalStatement::Memory(stmt) = stmt { + // Setup as unassigned, when we execute the memory + // statement (after evaluating expression), it should no + // longer be `Unassigned`. + let variable = &heap[stmt.variable]; + self.store.write(ValueId::Stack(variable.unique_id_in_scope as u32), Value::Unassigned); + cur_frame.prepare_single_expression(heap, stmt.initial_expr.upcast()); + } + }, Statement::If(stmt) => cur_frame.prepare_single_expression(heap, stmt.test), Statement::While(stmt) => cur_frame.prepare_single_expression(heap, stmt.test), Statement::Return(stmt) => {