Skip to content
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: error has incorrect column number #37180

Open
quackenbush opened this issue Feb 12, 2020 · 5 comments
Open

cmd/compile: error has incorrect column number #37180

quackenbush opened this issue Feb 12, 2020 · 5 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@quackenbush
Copy link

quackenbush commented Feb 12, 2020

What version of Go are you using (go version)?

$ go version
1.13.7

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/pdq/gocode"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.7"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.7/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/mv/slwhmwcj03d0npjtlsnjcm2m0000gn/T/go-build196033875=/tmp/go-build -gno-record-gcc-switches -fno-common"
pdq@quackbook-air ~/v/simscope $

What did you do?

Playground: https://play.golang.org/p/DyuvyvPwrv6

package main

type ABC struct {
	A string
}

func hello(first string, second string, third bool) {
}

func main() {
var abc ABC
hello("hello", "world", abc)
}

What did you expect to see?

./prog.go:12:24: cannot use abc (type ABC) as type bool in argument to hello

What did you see instead?

./prog.go:12:16: cannot use abc (type ABC) as type bool in argument to hello

NOTE: I removed leading whitespace in the source code to eliminate ambiguity.

The error is pointing to the second argument column ("world" on column 12) instead of the third argument column (abc on column 24).

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 12, 2020
@dmitshur dmitshur added this to the Backlog milestone Feb 12, 2020
@dmitshur dmitshur changed the title Compile error has incorrect column number cmd/compile: error has incorrect column number Feb 12, 2020
@dmitshur
Copy link
Contributor

Thanks for reporting. Do you know if this happens with older versions of Go too?

/cc @josharian @mdempsky @martisch per owners.

@quackenbush
Copy link
Author

I also tried with 1.11.13 and it gives the same incorrect column.

@mdempsky
Copy link
Member

Yeah, this is a known issue of the Go compiler's AST that we don't have precise column information for identifier use locations. I can't find an issue that captures this though.

A while back I tried preparing https://go-review.googlesource.com/c/go/+/38735 to fix this, but it had a non-negligible compiler performance impact (~4% for go/types and cmd/compile).

@quackenbush
Copy link
Author

Thanks. Not sure if this helps, but if I change "abc" to a primitive type, Go prints the correct column number in the error:

hello("hello", "world", 3.14)
./prog.go:12:25: cannot use 3.14 (type float64) as type bool in argument to hello

@mdempsky
Copy link
Member

Thanks, for confirming. That's consistent with the issue I was describing.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Status: Triage Backlog
Development

No branches or pull requests

4 participants