From 19aaba8eb81b861b64a5ca42ae51f446a89dca94 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Mon, 29 Jan 2018 18:05:11 +0300 Subject: [PATCH] if: int condition on stack top --- src/runner.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/runner.rs b/src/runner.rs index 0394c2b..fdd62c3 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -369,8 +369,11 @@ impl<'a, E: Externals> Interpreter<'a, E> { } fn run_if(&mut self, context: &mut FunctionContext, labels: &HashMap, block_type: BlockType) -> Result { - let branch = context.value_stack_mut().pop_as()?; - let block_frame_type = if branch { BlockFrameType::IfTrue } else { + let condition: bool = context + .value_stack_mut() + .pop_as() + .expect("Due to validation stack top should be an int"); + let block_frame_type = if condition { BlockFrameType::IfTrue } else { let else_pos = labels[&context.position]; if !labels.contains_key(&else_pos) { context.position = else_pos;