What version of Go are you using (go version)?
$ go version
go version go1.11.4 darwin/amd64
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
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/a.sulaev/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/a.sulaev/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11.4/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
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/wb/q3d56j697hs6zfvjgt3n88bc0000gp/T/go-build625061947=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
Here is the code + play.golang.org link on it :
package main
import (
"errors"
)
type SomeType struct{}
func (SomeType) Error() string {
return ""
}
func main() {
var x error
x = errors.New("aa")
switch x {
case x.(*SomeType):
println("*SomeType")
case x:
println("x")
}
// println(x.(*SomeType))
}
What did you expect to see?
I was expecting to see panic at the line case x.(*SomeType): because of the bad type casting.
For example if i uncomment the line // println(x.(*SomeType)) (which casts x the same way as in case) i get the panic
What did you see instead?
This code successfully compiles and prints "x" when running.
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env)?go envOutputWhat did you do?
Here is the code + play.golang.org link on it :
What did you expect to see?
I was expecting to see panic at the line
case x.(*SomeType):because of the bad type casting.For example if i uncomment the line
// println(x.(*SomeType))(which castsxthe same way as incase) i get the panicWhat did you see instead?
This code successfully compiles and prints "x" when running.