From 7d574f7b1c842f2675f945528b61064d599366d0 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 28 Jun 2016 15:06:44 +0200 Subject: [PATCH] don't execute the first statement of a constant/static/promoted right away This might create confusion, because attempting to execute a statement can cause arbitrary stackframes to be added for the constants/statics/promoteds required by that statement. Before this commit, the first statement of the last added stackframe was executed immediately. Thus there was no way to inspect the state before that first statement. --- src/interpreter/step.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/interpreter/step.rs b/src/interpreter/step.rs index 37a7aa4d01..6d4d8aad2c 100644 --- a/src/interpreter/step.rs +++ b/src/interpreter/step.rs @@ -39,11 +39,9 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { }.visit_statement(block, stmt); if current_stack == self.stack.len() { self.statement(stmt)?; - } else { - // ConstantExtractor added some new frames for statics/constants/promoteds - // self.step() can't be "done", so it can't return false - assert!(self.step()?); } + // if ConstantExtractor added new frames, we don't execute anything here + // but await the next call to step return Ok(true); } @@ -58,11 +56,9 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { }.visit_terminator(block, terminator); if current_stack == self.stack.len() { self.terminator(terminator)?; - } else { - // ConstantExtractor added some new frames for statics/constants/promoteds - // self.step() can't be "done", so it can't return false - assert!(self.step()?); } + // if ConstantExtractor added new frames, we don't execute anything here + // but await the next call to step Ok(true) }