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

F*: pattern matching is disallowed on usizes, isizes (+u128/i128/f32/f64) #464

Open
Tracked by #806
W95Psp opened this issue Jan 29, 2024 · 2 comments · May be fixed by #878
Open
Tracked by #806

F*: pattern matching is disallowed on usizes, isizes (+u128/i128/f32/f64) #464

W95Psp opened this issue Jan 29, 2024 · 2 comments · May be fixed by #878
Assignees
Labels
f* F* backend marked-unimplemented Issue refered by `Unimplemented {issue_id...}` in the engine

Comments

@W95Psp
Copy link
Collaborator

W95Psp commented Jan 29, 2024

Currently we do not support matching on usize in the F* backend.

This is because of our encoding of usize: a usize is defined as an opaque type being maybe a u16, a u32, or maybe a u64. This encoding is important since the size of usizes varies according to the architecture being targetted.

Solutions:

  • rewrite matches
  • define usize as a x: u64 {range (v x) u16_inttype \/ range (v x) u32_inttype \/ range (v x) u64_inttype} (wdyt about this @karthikbhargavan?)
@franziskuskiefer franziskuskiefer added the f* F* backend label Jan 30, 2024
@W95Psp W95Psp changed the title F*: pattern matching is disallowed on usizes F*: pattern matching is disallowed on usizes, isizes (+u128/i128) Apr 11, 2024
W95Psp added a commit that referenced this issue Apr 11, 2024
@W95Psp
Copy link
Collaborator Author

W95Psp commented Apr 11, 2024

The issue is that we do not know the size of usize on the target platform. So, it is better to cast the usize into u8or u16 or whatever in the pattern match:

match (x as u8) {.
  0 => ...
} ```

Originally posted by @karthikbhargavan in #598 (comment)

@franziskuskiefer
Copy link
Member

There's a design in #806 that needs to get implemented.

@maximebuyse maximebuyse linked a pull request Sep 4, 2024 that will close this issue
@W95Psp W95Psp added the marked-unimplemented Issue refered by `Unimplemented {issue_id...}` in the engine label Oct 2, 2024
@W95Psp W95Psp changed the title F*: pattern matching is disallowed on usizes, isizes (+u128/i128) F*: pattern matching is disallowed on usizes, isizes (+u128/i128/f32/f64) Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f* F* backend marked-unimplemented Issue refered by `Unimplemented {issue_id...}` in the engine
Projects
No open projects
Status: No status
Development

Successfully merging a pull request may close this issue.

3 participants