-
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: improve error message when if statement brace is on next line #18747
Comments
Happens all the same on @golang101 perhaps retitle to something like |
@golang101 thanks for filing issues. Would you mind helping the folks doing triage by identifying the relevant component in the issue title, when you know it? Thanks! cc @odeke-em |
@josharian did you mean that triage sentence towards me? I haven't requested github access, maybe I should. |
It was meant for @golang101. But you should definitely request GitHub access. |
@josharian I would like to. |
CL https://golang.org/cl/36317 mentions this issue. |
Syntactically,
is the same as
And the latter produces a "missing condition in if statement" error, which is why the former does too. It's not obvious that the former deserves a different error message; or that if it does, what exactly should be the criteria for producing something different. I'd like to establish that before we worry about CLs. |
@mdempsky, I bet only about 2% of Go users know that semicolons are even in the language at all, much less know the insertion rules. I personally think it deserves a better error message. A fair number of newcomers to the language are going to write code in that style before they discover gofmt. |
@mdempsky, yeah, I agree with @bradfitz's explanation, As we can see in the issue report, the user who reported it found the same problem. if condition
{
} wasn't intuitive since visually they already provided the condition Getting the same message for if expression; {
} that tells me to think about the missing condition in the style if expression; condition { even though |
…bracec is on next line For golang#18747.
… line A typical beginner mistake is to place the left brace on a new line: if condition { ... } Prior to this commit, the error message was misleading: missing condition in if statement Switch to a better error message: missing { after if clause Fixes golang#18747.
CL https://golang.org/cl/36930 mentions this issue. |
Use distinction between explicit and automatically inserted semicolons to provide a better error message if the condition in an 'if' statement is missing. For #18747. Change-Id: Iac167ae4e5ad53d2dc73f746b4dee9912434bb59 Reviewed-on: https://go-review.googlesource.com/36930 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This was fixed by https://go-review.googlesource.com/#/c/36930/. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.7.4 linux/amd64
What did you do?
What did you expect to see?
the two error messages should be alike.
What did you see instead?
the the second error message is not very accurate.
The text was updated successfully, but these errors were encountered: