Skip to content

cmd/compile: "invalid recursive type" should abort #28294

Closed

Description

@bep

This seems to be similar to #21273 (fixed in Go 1.10).

▶ go version
go version go1.11 darwin/amd64
package main

func main() {
	type int int
	type I int

	const i I = 1
}

The above fails with

./main.go:4:7: invalid recursive type int
./main.go:5:7: invalid recursive type I
./main.go:7:8: invalid constant type I

The above is clear enough in this small case, but I had this happen to me (again, an automatic refactoring gone wrong) in a bigger program and all I saw was a list of invalid constant type (that looked valid), and then too many errors.

Activity

  1. meirf commented on Oct 20, 2018

    @meirf
    Contributor

    Maybe this case should follow the same logic as here:

    There's no need to tell me T is an invalid map key after telling me it's an invalid anything.

    This case is trickier though since I is typed of the original error type.

    cc @griesemer

  2. self-assigned this
    on Oct 20, 2018
  3. added this to the Unplanned milestone on Oct 20, 2018
  4. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Oct 20, 2018
  5. griesemer commented on Mar 18, 2022

    @griesemer
    Contributor

    This is now (Go 1.18) reporting:

    ./prog.go:4:7: invalid recursive type int
    	./prog.go:4:7: int refers to
    	./prog.go:4:7: int
    

    which seems reasonable. Closing as working as expected.

  6. locked and limited conversation to collaborators on Jun 23, 2023
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.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions