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

bugfix: not-found or ambiguous constructor treated as var #5303

Merged
merged 3 commits into from
Aug 30, 2024

Conversation

mitchellwrosen
Copy link
Member

@mitchellwrosen mitchellwrosen commented Aug 28, 2024

Overview

Fixes #5301

This PR adjusts the parser to properly commit to a branch that fails to resolve a constructor pattern (either due to 0 or 2+ matches in the namespace).

Previously, code like

cases Foo X -> Y

would erroneously treat X as a variable binding if X didn't resolve to a single constructor in the namespace.

Test coverage

There's a transcript that captures the fix

@@ -465,7 +465,7 @@ result : '{e, Give T} r -> {e} r
result f = handle !f with cases
{ x } -> x
{ give _ -> resume } -> result resume
{ give A -> resume } -> result resume
{ give T.A -> resume } -> result resume
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test wasn't quite testing the right thing: since the A constructor is ambiguous in the namespace, it ended up as a variable, essentially testing:

{ give _ -> resume } -> result resume
{ give _ -> resume } -> result resume

rather than the intended

{ give _ -> resume } -> result resume
{ give T.A -> resume } -> result resume

but both produce the same output (complaining that the last pattern is redundant)

@mitchellwrosen mitchellwrosen marked this pull request as ready for review August 29, 2024 18:25
@aryairani aryairani merged commit 936b660 into trunk Aug 30, 2024
35 checks passed
@aryairani aryairani deleted the 24-08-27-parser-fix branch August 30, 2024 14:46
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.

out of scope data constructor in pattern is treated as a var
2 participants