-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/compile: give better error for composite literal parsing ambiguity #30867
Comments
Search for "parsing ambiguity" in https://golang.org/ref/spec#Composite_literals . I don't know whether the compiler could give a better error message. I'll retitle the issue for that. |
Do you still need someone to investigate this? |
The thing to investigate would be whether it is straightforward for the compiler to give a better error message for this case. If you want to look into it, go ahead, but please be aware that this is a subtle issue that will need to consider several different kinds of incorrect code to make sure that the error message does not become more misleading. Thanks. |
Ok thanks. I'll take a look and update here. |
I think the main complexity here is that the error message probably originates from the parser, and we don't know about types at that point, so I think it's impossible for a parser in the current state to tell whether |
I think this is rather complicated and would probably come up to be a hack. I looked into it and IMO it would add too much complexity to address it. I don't want that and since this is already documented I guess it can stay as it is. Closing as won't fix. Feel free to re-open if you can come up with a good and simple solution. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
Play link
What did you expect to see?
What did you see instead?
Please note that adding parentheses works
Is this intended? If so, shouldn't the compiler give better errors?
The text was updated successfully, but these errors were encountered: