From 59eb20a7b7390f7f4457388483529b3463a1e734 Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Tue, 28 Mar 2023 18:47:58 +0100 Subject: [PATCH] fix to stop VM on Trap opcode (#163) --- brillig_bytecode/src/lib.rs | 2 +- brillig_bytecode/src/opcodes.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/brillig_bytecode/src/lib.rs b/brillig_bytecode/src/lib.rs index 977e76450..3eb8978d5 100644 --- a/brillig_bytecode/src/lib.rs +++ b/brillig_bytecode/src/lib.rs @@ -38,7 +38,7 @@ impl VM { /// Loop over the bytecode and update the program counter pub fn process_opcodes(mut self) -> Registers { - while self.process_opcode() != VMStatus::Halted {} + while !matches!(self.process_opcode(), VMStatus::Halted | VMStatus::Failure) {} self.finish() } // Process a single opcode and modify the program counter diff --git a/brillig_bytecode/src/opcodes.rs b/brillig_bytecode/src/opcodes.rs index 7d711887b..e8e054401 100644 --- a/brillig_bytecode/src/opcodes.rs +++ b/brillig_bytecode/src/opcodes.rs @@ -65,7 +65,7 @@ pub enum Opcode { source: RegisterMemIndex, }, /// Used if execution fails during evaluation - Trap + Trap, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]