Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pop unneeded exprret from require #93

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/shared/src/flattened.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub enum FlatExpr {
},

Todo(Loc, &'static str),
Pop,

Emit(Loc),
TestCommand(Loc, &'static str),
Expand Down Expand Up @@ -399,6 +400,7 @@ impl FlatExpr {
| ArrayLiteral(loc, ..) => Some(*loc),

FunctionCallName(..)
| Pop
| YulExpr(FlatYulExpr::YulStartBlock(_))
| YulExpr(FlatYulExpr::YulEndBlock(_)) => None,
}
Expand Down
9 changes: 9 additions & 0 deletions crates/solc-expressions/src/context_builder/flattened.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(())
Expand Down
Loading