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: do not attempt to print type if unknown in "cannot convert" error message #23436

Closed
odeke-em opened this issue Jan 12, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@odeke-em
Copy link
Member

commented Jan 12, 2018

Please answer these questions before submitting your issue. Thanks!

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

go version devel +a6b9385 Thu Jan 4 21:55:42 2018 +0000 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

GOARCH="amd64"
GOBIN="/Users/emmanuelodeke/go/bin"
GOCACHE="/Users/emmanuelodeke/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/emmanuelodeke/go"
GORACE=""
GOROOT="/Users/emmanuelodeke/go/src/go.googlesource.com/go"
GOTMPDIR=""
GOTOOLDIR="/Users/emmanuelodeke/go/src/go.googlesource.com/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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/v3/7z434qpx5v3bw0wh8h2myfpw0000gn/T/go-build865828038=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Given this code https://play.golang.org/p/aDVRtb8yKMe
or inlined below

package main

func main() {
	if i := 0; i == nil {
	}
}

What did you expect to see?

prog.go:4:15: cannot convert nil to type int
as it does for Go1.9 and before

What did you see instead?

prog.go:4:15: cannot convert nil () to type int

While the current disambiguation of including the type in the error is quite nice, it's a minor oversight that we forgot to check first if the type is nil before trying to print the type by it's print verb. I think this issue is a low hanging fruit that we can fix for Go1.10 since it is even a regression anyways but more importantly IMHO we'll have a whole lot of odd error messages for Go1.10 if we don't fix it #elevatorPitchToFixIt

@odeke-em odeke-em changed the title cmd/compile: do not attempt to print type if unknown cmd/compile: do not attempt to print type if unknown in "cannot convert" error message Jan 12, 2018

@odeke-em

This comment has been minimized.

Copy link
Member Author

commented Jan 12, 2018

Hmm, I can't reproduce this bug in a weird twist, perhaps this was just a change that I had made with my local version. My apologies for the false alarm, there is no issue here.

@odeke-em odeke-em closed this Jan 12, 2018

@golang golang locked and limited conversation to collaborators Jan 12, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.