Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

go/types: panic("t.fromRHS = %s, typ = %s") in setDefType #71029

Open
adonovan opened this issue Dec 26, 2024 · 4 comments
Open

go/types: panic("t.fromRHS = %s, typ = %s") in setDefType #71029

adonovan opened this issue Dec 26, 2024 · 4 comments
Assignees
Labels
gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@adonovan
Copy link
Member

adonovan commented Dec 26, 2024

#!stacks
"runtime.gopanic" && "setDefType:+7"

Issue created by stacks.

func setDefType(def *TypeName, typ Type) {
	if def != nil {
		switch t := def.typ.(type) {
		case *Alias:
			// t.fromRHS should always be set, either to an invalid type
			// in the beginning, or to typ in certain cyclic declarations.
			if t.fromRHS != Typ[Invalid] && t.fromRHS != typ {
				panic(sprintf(nil, nil, true, "t.fromRHS = %s, typ = %s\n", t.fromRHS, typ))
			}
			t.fromRHS = typ
		case *Basic:
			assert(t == Typ[Invalid])
		case *Named:
			t.underlying = typ
		default:
			panic(fmt.Sprintf("unexpected type %T", t))
		}
	}
}

This stack PrtfKQ was reported by telemetry:

golang.org/x/tools/gopls@v0.17.1 go1.23.4 linux/amd64 vscode (1)

cc @timothy-king

@adonovan adonovan added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. gopls/telemetry-wins labels Dec 26, 2024
@prattmic
Copy link
Member

#71010 in the compiler might be the same bug?

@adonovan
Copy link
Member Author

Yep!

Hey, you're using stacks for the compiler now? Nice!

@prattmic
Copy link
Member

I've got a hacked up version in https://go.dev/cl/638775, but it needs clean up to support both gopls and the compiler.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants