From 810b8ee4d0d8a1fa4be05f1fc92b04c717c16235 Mon Sep 17 00:00:00 2001 From: Aviv Palivoda Date: Sat, 4 May 2019 17:19:59 +0300 Subject: [PATCH] Simplify PopException --- vm/src/frame.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/vm/src/frame.rs b/vm/src/frame.rs index c22ad8897..ddddad91e 100644 --- a/vm/src/frame.rs +++ b/vm/src/frame.rs @@ -862,14 +862,13 @@ impl Frame { Ok(None) } bytecode::Instruction::PopException {} => { - assert!(vm.pop_exception().is_some()); - let block = self.pop_block(); - assert!(block.is_some()); - match block.unwrap().typ { - BlockType::ExceptHandler => (), - _ => assert!(false), - }; - Ok(None) + let block = self.pop_block().unwrap(); // this asserts that the block is_some. + if let BlockType::ExceptHandler = block.typ { + assert!(vm.pop_exception().is_some()); + Ok(None) + } else { + panic!("Block type must be ExceptHandler here.") + } } } }