-
Notifications
You must be signed in to change notification settings - Fork 18k
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
runtime: assignment to nil map panics with string, not Error type #14965
Comments
There are cases like this in chan.go and select.go also, and perhaps error.go as well. In general any panic("string") in non-test code in the runtime is suspect, except for cases like panic("not reached"). |
we can define a new string type that implements
error in runtime for those cases.
|
Should some of these be throw cases, not panic cases? I think most of these On Mon, 28 Mar 2016, 10:01 Minux Ma, notifications@github.com wrote:
|
@minux we already have errorString @davecheney IMO I think we could do this in a separate issue as that changes the behavior as opposed to first fixing this issue and conforming to the docs that say panics from the runtime should be with Error's as defined here https://golang.org/ref/spec#Run_time_panics. |
what's your proposal?
I don't want to change any existing outside-visible behavior,
except making those panic implements runtime.Error.
|
@minux thanks. In this case, we have no other option then but to define a new string type. |
CL https://golang.org/cl/21214 mentions this issue. |
Please answer these questions before submitting your issue. Thanks!
go version
)?$ go version
go version go1.6 linux/amd64
go env
)?$ go env
GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
Assignment to a nil map.
http://play.golang.org/p/ES8UfghkFv
assignment to nil map should panic with type Error as specified here:
https://golang.org/ref/spec#Run_time_panics
assignment to nil map panics with type String
The text was updated successfully, but these errors were encountered: