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

Infer if fields are mutated #99

Open
yannbolliger opened this issue Mar 4, 2021 · 1 comment
Open

Infer if fields are mutated #99

yannbolliger opened this issue Mar 4, 2021 · 1 comment
Labels
enhancement Improvement to an existing feature feature Something needs to be added imperative Feature or bug related to imperative features

Comments

@yannbolliger
Copy link
Collaborator

Currently (as of #98), the user has to annotate all the fields, they will ever mutate with assignments:

#[var(field)]
struct S {
  field: i32,
}
fn main() {
  let mut s = S { field: 123 };
  // otherwise, this fails in Stainless:
  s.field = 456;
}

This is weird in Rust, because there, the data structure is agnostic to whether it will be mutated or not. Only the place where it is stored decides about mutability. Therefore, we'd like to infer which fields are mutated in a program and automatically add the @var flag to those – relying on Rust's borrow checker to guard against forbidden mutation.

@yannbolliger yannbolliger added enhancement Improvement to an existing feature feature Something needs to be added imperative Feature or bug related to imperative features labels Mar 4, 2021
@yannbolliger
Copy link
Collaborator Author

yannbolliger commented Mar 11, 2021

Or have everything as @var because logically, that is correct in Rust? Might break verification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to an existing feature feature Something needs to be added imperative Feature or bug related to imperative features
Projects
None yet
1 participant