-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: incorrect name in error message #21747
Comments
@dsnet it seems like the new error is a premature report, but on tip it currently reports Go1.8$ go version && go run main.go
go version go1.8.3 darwin/amd64
# command-line-arguments
./main.go:3: undefined: x Go1.9+$ go version && go run main.go
go version devel +f74b52c Fri Sep 1 00:42:21 2017 +0000 darwin/amd64
# command-line-arguments
./main.go:3:6: missing function body for "_"
./main.go:3:7: undefined: x I guess we should report |
Interesting. I'm inclined to just truncate the We can continue including the name, but it's actually complicated somewhat because of type aliases (which is why this changed in 1.9). |
Change https://golang.org/cl/61311 mentions this issue: |
For posterity, the two changes that happened in 1.9 that are relevant to this issue:
If we decide we want to restore the function name, moving the error to type checking would probably work too. |
I think dropping the function name is sufficient since the line should be sufficient. Usually there isn't more than one function declaration on a single line. |
Reopening for cherry picking to the Go1.9.1 branch. |
@dsnet Yeah, and even if there were multiple functions on a single line, we now have column information. We also don't include function name in any other (standard) error messages. (We do include it in some optional diagnostics used for debugging the compiler itself.) |
This is a bad-error-on-invalid. I'm not sure this qualifies for a 1.9 backport. |
CL 61311 OK for Go 1.9.2. Not really worth fixing, but the fix is hilarious. |
Change https://golang.org/cl/70972 mentions this issue: |
…error message Fixes #21747. Change-Id: I6a68370be3b7510ce364ddd1e41a1d767ce3a67f Reviewed-on: https://go-review.googlesource.com/61311 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-on: https://go-review.googlesource.com/70972 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
go1.9.2 has been packaged and includes: The release is posted at golang.org/dl. — golang.org/x/build/cmd/releasebot, Oct 26 21:09:13 UTC |
Consider the following (invalid) Go code:
The Go1.9 compiler complains with:
On Go1.8, it complained with:
Edit: added
type x struct{}
The text was updated successfully, but these errors were encountered: