-
Notifications
You must be signed in to change notification settings - Fork 1.1k
DuplicateBind error triggered by same variable name in alternative pattern #1612
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
Comments
Tagging @DarkDimius and @liufengyun at @felixmulder request. |
There's clearly an error here, but not the one that's flagged. scalac says: error: illegal variable in pattern alternative |
@odersky This is actually how I found this bug, I was attempting to improve the error message for "illegal variable in pattern alternative" and found I could not trigger the error message in Dotty as I could in Scala. |
@ShaneDelmore You want to give it a try to add the error message? I believe it should be in Typer. The thing to watch out for are Bind nodes that bind a name other than |
I will take a look at it this weekend and see if I can make any headway on it. |
I started looking into this bug last weekend and think I should be able to come up with a fix. Besides the error message, is there any reason not to just allow multiple variable bindings if they exist in every alternative with the same name and same type? |
This sounds like a judgement call for @odersky, the spec doesn't specifically prohibit this. It might make the desugaring inside |
Duplicate of #3332. |
I believe the issue is in Typer.transform. Here is an example snippet and output:
On compile this error is returned:
The text was updated successfully, but these errors were encountered: