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

internal compile error caused by function type alias #36419

Closed
mdavis-ciena opened this issue Jan 7, 2020 · 6 comments
Closed

internal compile error caused by function type alias #36419

mdavis-ciena opened this issue Jan 7, 2020 · 6 comments

Comments

@mdavis-ciena
Copy link

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

$ go version
go version go1.13.5 linux/amd64

Does this issue reproduce with the latest release?

Yes (haven't tried 1.14beta1).

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/mdavis/.cache/go-build"
GOENV="/home/mdavis/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/mdavis/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build066272323=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Compile the following source using go build bug.go:

package pkg

type I interface {
    M(FT)
}

type S struct {
    F FT
}

type FT = func(S)

All of the shown components seem to be necessary. In particular, the compile error disappears if any of the following are done:

  1. Remove the interface I, its method M or that method's argument (or change the argument type).
  2. Remove the field F of S (or change its type).
  3. Remove the argument of the function type (or change the argument's type).
  4. Change the type alias to a type definition (remove the "=").

What did you expect to see?

Successful compilation (no output).

What did you see instead?

# command-line-arguments
./bug.go:11:6: internal compiler error: cannot handle alias type declaration (issue #25838): FT

Please file a bug report including a short program that triggers the error.
https://golang.org/issue/new
@cuonglm
Copy link
Member

cuonglm commented Jan 7, 2020

There's an issue for tracking this bug #25838

@mdavis-ciena
Copy link
Author

This is not contrived, but a problem that is distilled WAAAAAAY down from a logging library that I am writing. A struct type holds references to functions that reconfigure child objects by taking and returning the struct type (along with other parameters), etc.

@mdavis-ciena
Copy link
Author

@cuonglm - Thanks. That was referenced in the compile output, but since it mentioned reporting the bug here, I did.

@mdavis-ciena
Copy link
Author

Confirmed the compile error also goes away if interface I is defined last.

@cuonglm
Copy link
Member

cuonglm commented Jan 7, 2020

@cuonglm - Thanks. That was referenced in the compile output, but since it mentioned reporting the bug here, I did.

The error message points you to #25838, so you should not fire new issue, they're just duplicated.

@mdavis-ciena
Copy link
Author

All right. Should I file a new bug report about the error message that literally says:

... (issue #25838)...Please file a bug report including a short program that triggers the error.

then?

@golang golang locked and limited conversation to collaborators Jan 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants