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

mode-checking for struct patterns mismatches fields #348

Closed
tjhance opened this issue Jan 5, 2023 · 1 comment
Closed

mode-checking for struct patterns mismatches fields #348

tjhance opened this issue Jan 5, 2023 · 1 comment

Comments

@tjhance
Copy link
Collaborator

tjhance commented Jan 5, 2023

This wrongly passes mode-checking (it actually fails due to an unrelated erasure error, but this issue isn't about that):

struct Foo {
    #[spec] a: u64,
    #[proof] b: u64,
}

#[proof]
fn some_call(#[spec] x: u64, #[proof] y: u64) { }

#[proof]
fn t() {
    #[proof] let foo = Foo { a: 5, b: 6 };
    #[proof] let Foo { b, a } = foo;

    some_call(b, a);
}

Meanwhile, this wrongly gives an error:

#[proof]
fn t() {
    #[proof] let foo = Foo { a: 5, b: 6 };
    #[proof] let Foo { b, a } = foo;

    some_call(a, b);
}
error: expression has mode spec, expected mode proof
  --> test_pat_destruct.rs:26:18
   |
26 |     some_call(a, b);
   |                  ^

It looks like mode-checking doesn't handle let Foo { b, a } correctly because the order of its fields are wrong.

@tjhance
Copy link
Collaborator Author

tjhance commented Feb 2, 2023

fixed by 9eb7b12

@tjhance tjhance closed this as completed Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant