-
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 column number in build error for unused variable #21317
Comments
Another example which I most likely the same issue but it is confusing when the editor is highlighting the wrong identifier:
Column 6, in this case, is the first argument to the Foo function call, but the problem is with the second argument. |
Haven't checked if it's a duplicate but this can be improved for sure. |
This is what a code editor that displays issues inline shows the user: Note that it visually points to the 3rd parameter, the empty string, very prominently. However, the actual issue is that the Emitting an incorrect column is an issue that is magnified in the case of editors that visualize that information more prominently than what's visible by glancing at terminal output only. |
@griesemer This is a feature that's new to Go 1.9, and it has a bug. What's the reason this issue is added to Go 1.10 milestone instead of 1.9? Is it because the bug is considered to be minor and happens only in a few cases, so the feature is still overall helpful and worth being included, despite the incorrect behavior in this particular case? |
@shurcooL It's not a show stopper. Yes, it's a new feature, and we know it has bugs (mostly due to the nature of how the existing code deals with position information). It can be disabled with the -C cmd/compile flag. It's definitively minor, even though it's annoying and perhaps confusing if one is using an IDE and not very familiar with the language. We will fix all these over time and the intention is to have 100% accurate positions. |
Great news, seems like @mdempsky fixed this issue with commit f22ef70 and CL https://go-review.googlesource.com/c/66810/ $ go version && go run main.go
go version devel +32f994a Mon Nov 6 07:09:50 2017 +0000 darwin/amd64
# command-line-arguments
./main.go:6:9: n declared and not used
./main.go:6:12: err declared and not used I'll submit a test to ensure we don't regress. |
Change https://golang.org/cl/76150 mentions this issue: |
Updates #21317 @mdempsky fixed issue #21317 with CL 66810, so lock a test in to ensure we don't regress. The test is manual for now before test/run.go has support for matching column numbers so do it old school and match expected output after an exec. Change-Id: I6c2a66ddf04248f79d17ed7033a3280d50e41562 Reviewed-on: https://go-review.googlesource.com/76150 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Alright, the regress test addressed by CL https://go-review.googlesource.com/c/go/+/76150 and commit 0c55495. Please get the latest code. |
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
Run this program with
go build
What did you expect to see?
Note the column numbers.
What did you see instead?
Column 22 for the above program is the argument to the
fmt.Print
function. There's nothing wrong with the argument, the problem is with the returned arguments.It appears this may be a known issue, mentioned in 2a5cf48 but it's not clear whether this is the same issue.
At the very least, when the editor is highlighting the argument but the error is elsewhere on the same line, it's confusing.
The text was updated successfully, but these errors were encountered: