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

Wrong type ascription pattern in generated F* #1170

Closed
maximebuyse opened this issue Dec 4, 2024 · 2 comments · Fixed by #1174
Closed

Wrong type ascription pattern in generated F* #1170

maximebuyse opened this issue Dec 4, 2024 · 2 comments · Fixed by #1174
Assignees
Labels
bug Something isn't working f* F* backend

Comments

@maximebuyse
Copy link
Contributor

struct Other<'a>(&'a i32);

enum Test<'a> {
    C1(Other<'a>)
}

impl<'a> Test<'a> {
    fn test(&self) -> i32 {
        match self {
            Self::C1(c) => *c.0

        }
    }
}

Open this code snippet in the playground

The generated F* for the test method from the example is:

let impl__test (self: t_Test) : i32 =
  match self with
  | (Test_C1 c: t_Test) -> c._0

F* rejects it with Type ascriptions within patterns are only allowed on variables

@maximebuyse maximebuyse added bug Something isn't working f* F* backend labels Dec 4, 2024
@franziskuskiefer
Copy link
Member

Don't put any type annotations here.

@maximebuyse maximebuyse self-assigned this Dec 9, 2024
@maximebuyse
Copy link
Contributor Author

As F* allows type ascription patterns only on variables, my first attempt is to remove the type ascription (and keep only the underlying pattern) except when the underlying pattern is a binding pattern.

However what I understand from the Rust doc on patterns an this canceled feature is that type ascription patterns in Rust are allowed only in let bindings so I think we could actually completely ignore them in the F* backend (even when they wrap a binding pattern) but both solutions are probably fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working f* F* backend
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants