Skip to content

cmd/compile: false positive error about recursive type aliases #23055

Closed
@mdempsky

Description

@mdempsky

cmd/compile erroneously emits an "invalid recursive type alias" error for:

package p

type a struct { b }
type b = c
type c struct { *b }

Related: #18640

Activity

added this to the Go1.11 milestone on Dec 8, 2017
added
NeedsFixThe path to resolution is known, but the work has not been done.
on Dec 8, 2017
JicLotus

JicLotus commented on Dec 10, 2017

@JicLotus

Hi, i want to take this issue.

mdempsky

mdempsky commented on Dec 11, 2017

@mdempsky
ContributorAuthor

@JicLotus Thanks for volunteering. If you'd like to work on this, feel free. I do want to caution though that this is likely to be a fairly subtle and involved part of the compiler.

The problem is that we recursively evaluate type declarations as needed. I think we'll need to undo this and instead evaluate type declarations in a two pass algorithm:

  1. Set up a TFORW type for each package-scoped declared type and associate the Sym with that type.
  2. Resolve each type declaration and assign the TFORW type's underlying type.

I'm suspecting we'll also have to split constant evaluation into a separate pass too. I briefly touched on this idea in #13890 (comment). But it might be possible to fix this issue without doing that.

JicLotus

JicLotus commented on Dec 11, 2017

@JicLotus

Great @mdempsky

griesemer

griesemer commented on May 31, 2018

@griesemer
Contributor

I'm going to close this one as it is fundamentally a duplicate of #18640 (which has been reopened); see here.

locked and limited conversation to collaborators on May 31, 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

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @mdempsky@rasky@griesemer@gopherbot@JicLotus

        Issue actions

          cmd/compile: false positive error about recursive type aliases · Issue #23055 · golang/go