Skip to content

cmd/compile: invalid recursive type #27267

Closed
@QuantumGhost

Description

@QuantumGhost

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

go version go1.11 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=""
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11/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/02/nfvdwz45077g85khfsv07khm0000gn/T/go-build787448559=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

https://play.golang.org/p/SMcx3vUC83W
Compile this code with Go 1.11 and Go 1.10.3 respectively.

What did you expect to see?

Code compiles without any error with both Go 1.11 and Go 1.10.3.

What did you see instead?

Go 1.11 failed to compile this code with the following error:
On my machine:

❯ go build recur.go
# command-line-arguments
./recur.go:10:6: invalid recursive type Executor
./recur.go:16:29: cannot use callback (type func(*Executor) error) as type Executor in field value
./recur.go:21:19: cannot call non-function e.callback (type Executor)

Go 1.10.3 succeeded without any issue.

Activity

agnivade

agnivade commented on Aug 27, 2018

@agnivade
Contributor

Likely a duplicate of #27232.

/cc @josharian @mdempsky

changed the title [-]Simple code containing recursive type definition failed to compile under Go 1.11[/-] [+]cmd/compile: invalid recursive type[/+] on Aug 27, 2018
added
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
on Aug 27, 2018
added this to the Go1.12 milestone on Aug 27, 2018
josharian

josharian commented on Aug 27, 2018

@josharian
Contributor

Likely a duplicate of #27232.

Indeed.

This and #27232 are more in the domain of @mdempsky or @griesemer than me. (And I also don't have much time at the moment, and these seem like important fixes that could use a prompt backport.)

self-assigned this
on Aug 28, 2018
FiloSottile

FiloSottile commented on Aug 30, 2018

@FiloSottile
Contributor

(If this turns out NOT to be a duplicate of #27232, please open a separate backport issue.)

griesemer

griesemer commented on Sep 5, 2018

@griesemer
Contributor

Simpler reproducer, with irrelevant details stripped:

package p

type F = func(E) // compiles if not type alias or moved below E struct

type E struct {
	f F
}

var _ = E{func(E) {}}

This looks very much like a duplicate of #27232, though with different details. Leaving open until we know more.

griesemer

griesemer commented on Oct 29, 2018

@griesemer
Contributor

Simpler reproducer:

package p

type P = *S

type S struct {
	p P
}

The problem appears to be an incorrectly built type data structure for S after type-checking, such that the type of S.p is S rather than *S. The consequence is the error when calling checkwidth.

griesemer

griesemer commented on Oct 31, 2018

@griesemer
Contributor

Probably a duplicate of #25838. Leaving open for now.

gopherbot

gopherbot commented on Nov 3, 2018

@gopherbot
Contributor

Change https://golang.org/cl/147286 mentions this issue: cmd/compile: reintroduce work-around for cyclic alias declarations

gopherbot

gopherbot commented on Nov 26, 2018

@gopherbot
Contributor

Change https://golang.org/cl/151339 mentions this issue: [release-branch.go1.11] cmd/compile: reintroduce work-around for cyclic alias declarations

added a commit that references this issue on Nov 30, 2018
locked and limited conversation to collaborators on Nov 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.release-blocker

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @josharian@FiloSottile@agnivade@QuantumGhost@griesemer

        Issue actions

          cmd/compile: invalid recursive type · Issue #27267 · golang/go