From 522fa20983c3ab6a2e7dca972f4c927aae746aa9 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Tue, 20 Mar 2018 13:09:51 +0300 Subject: [PATCH] Fix br_if and then tee_local validation. (#76) --- src/validation/func.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/validation/func.rs b/src/validation/func.rs index 226ea0a..1145644 100644 --- a/src/validation/func.rs +++ b/src/validation/func.rs @@ -371,10 +371,7 @@ impl Validator { fn validate_tee_local(context: &mut FunctionValidationContext, index: u32) -> Result { let local_type = context.require_local(index)?; - let value_type = context.tee_value(StackValueType::Any)?; - if local_type != value_type { - return Err(Error(format!("Trying to update local {} of type {:?} with value of type {:?}", index, local_type, value_type))); - } + context.tee_value(local_type)?; Ok(InstructionOutcome::ValidateNextInstruction) } @@ -641,10 +638,10 @@ impl<'a> FunctionValidationContext<'a> { } } - fn tee_value(&mut self, value_type: StackValueType) -> Result { - let value = self.pop_value(value_type)?; - self.push_value(value)?; - Ok(value) + fn tee_value(&mut self, value_type: StackValueType) -> Result<(), Error> { + let _ = self.pop_value(value_type)?; + self.push_value(value_type)?; + Ok(()) } fn unreachable(&mut self) -> Result<(), Error> {