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/internal/types2, go/types: don't panic when calling under/underlying #65344

Open
paulsonkoly opened this issue Jan 29, 2024 · 5 comments
Assignees
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

@paulsonkoly
Copy link

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

$ go version
go version go1.21.6 darwin/arm64

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
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/phaul/Library/Caches/go-build'
GOENV='/Users/phaul/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/phaul/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/phaul/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/phaul/.asdf/installs/golang/1.21.6/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/phaul/.asdf/installs/golang/1.21.6/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.6'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/7f/z0kc3pxd6wz4540t2drzzlwm0000gn/T/go-build2303253187=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOROOT/bin/go version: go version go1.21.6 darwin/arm64
GOROOT/bin/go tool compile -V: compile version go1.21.6
uname -v: Darwin Kernel Version 23.3.0: Wed Dec 20 21:33:31 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T8112
ProductName:		macOS
ProductVersion:		14.3
BuildVersion:		23D56
lldb --version: lldb-1500.0.200.58
Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)

What did you do?

The following code snippet panics the compiler:

package main

type X Int

const (
  Invalid = X(iota)
  Call
  Int
)

func main () {

}

What did you expect to see?

Some errors reported

What did you see instead?

phaul@192 ~ % go build x.go
# command-line-arguments
: internal compiler error: panic: nil underlying

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new
@paulsonkoly
Copy link
Author

paulsonkoly commented Jan 29, 2024

more minimal example:

package main

type X Int

const Int = X(3)

func main () {

}

@mauri870 mauri870 added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. compiler/runtime Issues related to the Go compiler and/or runtime. labels Jan 29, 2024
@mauri870 mauri870 changed the title compiler internal error / panic cmd/compile: compiler internal error / panic Jan 29, 2024
@mauri870
Copy link
Member

cc @golang/compiler

@cuonglm
Copy link
Member

cuonglm commented Jan 29, 2024

This seems to be problem in types2, since go1.17 and go.18 with -G=0 reports an error:

$ cat p.go
package p

type X Int

const Int = X(3)

$ go1.17.13 tool compile p.go                            
p.go:5:14: cannot convert 3 (type int) to type X

cc @griesemer @findleyr

@cherrymui cherrymui added this to the Backlog milestone Jan 29, 2024
@griesemer griesemer self-assigned this Jan 29, 2024
@griesemer griesemer modified the milestones: Backlog, Go1.23 Jan 29, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/559335 mentions this issue: go/types, types2: bail early if we want a type but don't have one

gopherbot pushed a commit that referenced this issue Feb 5, 2024
If we do know whether we need a type or not, make use of the
information when we know that we don't have a type and bail out.

Fixes the issue at hand and also improves some other error messages
which now report that we don't have a type instead of reporting a cycle.

For #65344.

Change-Id: I11182efd452c485d89e6c09ead8a647ea05d7318
Reviewed-on: https://go-review.googlesource.com/c/go/+/559335
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
@griesemer
Copy link
Contributor

The specific issue at hand has been fixed with the above CL.
Retitling for broader issue (should not panic when calling under).

@griesemer griesemer changed the title cmd/compile: compiler internal error / panic types2, go/types: don't panic when calling under/underlying Feb 6, 2024
@griesemer griesemer modified the milestones: Go1.23, Backlog Feb 6, 2024
ezz-no pushed a commit to ezz-no/go-ezzno that referenced this issue Feb 18, 2024
If we do know whether we need a type or not, make use of the
information when we know that we don't have a type and bail out.

Fixes the issue at hand and also improves some other error messages
which now report that we don't have a type instead of reporting a cycle.

For golang#65344.

Change-Id: I11182efd452c485d89e6c09ead8a647ea05d7318
Reviewed-on: https://go-review.googlesource.com/c/go/+/559335
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
@dmitshur dmitshur changed the title types2, go/types: don't panic when calling under/underlying cmd/compile/internal/types2, go/types: don't panic when calling under/underlying May 17, 2024
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
Development

No branches or pull requests

6 participants