-
Notifications
You must be signed in to change notification settings - Fork 92
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
History Expressions #2993
History Expressions #2993
Conversation
/// This doesn't do anything fancy, it's just to make sure the way that history | ||
/// expressions are treated in contract checks and replaces is uniform. | ||
pub fn create_history_expr_bindings(history_expressions: &[(Ident, Expr)]) -> TokenStream2 { | ||
let history_variables = history_expressions.iter().map(|(v, _)| v); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be
let (history_variables, history_exprs) = history_expressions.iter().unzip();
instead of creating two iters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unzip
requires creation of two intermediate vectors though because it doesn't split into an iterator but has to be collected.
This seems like it would cause problems with the result ident since all idents are lifted, or in the event of someone making a locally bound variable within a closure, so something like Here is an example of something reasonable that breaks
Here is another example of something reasonable that breaks
|
Add support for History Expressions. This allows an
ensures
clause to evaluate expressions before the function runs, bing them to anonymous variables and use them after calculating the result to be able to compare to the state before the function evaluation.TODO
old
is implementedclone
and not usingclone
respectively for a referenceold
old
old
, e.g.old(... old( ) ... )
Resolves #2803
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.