From ba091647fd5436098d333b166c7aa7d25a4387a2 Mon Sep 17 00:00:00 2001 From: brock elmore Date: Thu, 1 Aug 2024 22:06:11 -0700 Subject: [PATCH] add pop after require --- crates/shared/src/flattened.rs | 2 ++ crates/solc-expressions/src/context_builder/flattened.rs | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/crates/shared/src/flattened.rs b/crates/shared/src/flattened.rs index 5fd487df..3104400e 100644 --- a/crates/shared/src/flattened.rs +++ b/crates/shared/src/flattened.rs @@ -38,6 +38,7 @@ pub enum FlatExpr { }, Todo(Loc, &'static str), + Pop, Emit(Loc), TestCommand(Loc, &'static str), @@ -399,6 +400,7 @@ impl FlatExpr { | ArrayLiteral(loc, ..) => Some(*loc), FunctionCallName(..) + | Pop | YulExpr(FlatYulExpr::YulStartBlock(_)) | YulExpr(FlatYulExpr::YulEndBlock(_)) => None, } diff --git a/crates/solc-expressions/src/context_builder/flattened.rs b/crates/solc-expressions/src/context_builder/flattened.rs index faaa8430..cc72b32e 100644 --- a/crates/solc-expressions/src/context_builder/flattened.rs +++ b/crates/solc-expressions/src/context_builder/flattened.rs @@ -869,6 +869,9 @@ pub trait Flatten: }); let cmp = self.expr_stack_mut().pop().unwrap(); self.traverse_requirement(cmp, *loc); + if input_exprs.len() > 1 { + self.push_expr(FlatExpr::Pop); + } } _ => { // func(inputs) @@ -1173,6 +1176,12 @@ pub trait Flatten: // Semi useless Super(..) => unreachable!(), Parameter(_, _, _) => Ok(()), + Pop => { + let _ = ctx + .pop_n_latest_exprs(1, Loc::Implicit, self) + .into_expr_err(Loc::Implicit)?; + Ok(()) + } Emit(loc) => { let _ = ctx.pop_n_latest_exprs(1, loc, self).into_expr_err(loc)?; Ok(())