fix(compiler): Handle non-exhaustive record patterns#2274
Merged
ospencer merged 3 commits intoApr 22, 2025
Conversation
ospencer
reviewed
Apr 22, 2025
ospencer
approved these changes
Apr 22, 2025
Member
ospencer
left a comment
There was a problem hiding this comment.
Looks good; thanks for getting this implemented.
exhaustive checking on records
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This implements exhaustiveness checking both for regular records and inline records. I split the two into seperate commits as we need the record pattern logic for inline adt's but some additional debugging was needed to get inlines working.
Record Exhaustiveness
I mostly ported the logic over from parmatch.ml in the ocaml compiler, though they are not 1 for 1 as our implementation has diverged a decent bit, the foundational logic is the same.
Inline ADT Records
It was a little weird that previously including a record variant would cause you to get no exhaustiveness info even on non record variants in your enum, it turned out this was because when converting back to our parsetree nodes we were just treating everything as a tuple causing a
misused_inline_recorderror internally.Changes to
queue.gr,mixedPatternMatching.grThis actually revealed some cases we missed, so I implemented them, the case in
queue.grwould never actually be possible because of how we build the queues.Closes: #2221, #2219