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

Allow empty record patterns #3321

Merged
merged 7 commits into from
Jun 20, 2024
Merged

Conversation

mtzguido
Copy link
Member

Related to #3320, I noticed we cannot write matches over a record without specifying one of its fields. The pattern {} does not even parse, and will not desugar even if it did. I think this comes from when we really needed to resolve the fields immediately to find the record type, but now that we have unresolved record constructors and projectors, we definitely can allow empty patterns.

The patch seems easy enough and we can now write something like this:

type t =
  | A { x:int; y:int }
  | B { z:bool }

let is_A (x:t) : bool =
  match x with
  | A {} -> true
  | _ -> false

@mtzguido
Copy link
Member Author

I don't think this should be controversial, so merging.

@mtzguido mtzguido merged commit c383918 into FStarLang:master Jun 20, 2024
2 checks passed
@mtzguido mtzguido deleted the empty_record_pattern branch June 20, 2024 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant