Skip to content

Commit

Permalink
Keep track of whether we must break or not
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite committed Jan 20, 2025
1 parent 3153058 commit 0354c2c
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions compiler/noirc_frontend/src/hir/comptime/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1730,17 +1730,21 @@ impl<'local, 'interner> Interpreter<'local, 'interner> {
self.push_scope();
self.current_scope_mut().insert(for_.identifier.id, make_value(i));

match self.evaluate(for_.block) {
Ok(_) => (),
Err(InterpreterError::Break) => break,
Err(InterpreterError::Continue) => continue,
let must_break = match self.evaluate(for_.block) {
Ok(_) => false,
Err(InterpreterError::Break) => true,
Err(InterpreterError::Continue) => false,
Err(error) => {
result = Err(error);
break;
true
}
}
};

self.pop_scope();

if must_break {
break;
}
}

self.in_loop = was_in_loop;
Expand All @@ -1756,18 +1760,22 @@ impl<'local, 'interner> Interpreter<'local, 'interner> {
loop {
self.push_scope();

match self.evaluate(expr) {
Ok(_) => (),
Err(InterpreterError::Break) => break,
Err(InterpreterError::Continue) => continue,
let must_break = match self.evaluate(expr) {
Ok(_) => false,
Err(InterpreterError::Break) => true,
Err(InterpreterError::Continue) => false,
Err(error) => {
result = Err(error);
break;
true
}
}
};

self.pop_scope();

if must_break {
break;
}

counter += 1;
if in_lsp && counter == 10_000 {
let location = self.elaborator.interner.expr_location(&expr);
Expand Down

0 comments on commit 0354c2c

Please sign in to comment.