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

go/types, types2: panic when type-checking invalid constant initializers #59603

Closed
findleyr opened this issue Apr 13, 2023 · 2 comments
Closed
Assignees
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@findleyr
Copy link
Contributor

Following https://go.dev/cl/478715, type-checking the following two packages causes an assertion failure inside of go/types:

-- lib.go --
package lib
const C = undef
-- p.go --
package p
import "lib"
const _ = lib.C

The problem is that undefined constants are imported as valid operands.

This is actually tricky to fix forward, as certain imports must have invalid type, initially (specifically: functions in the unsafe package). Therefore, I think we should revert that CL, putting back the defensive logic.

CC @griesemer

@findleyr findleyr added this to the Go1.21 milestone Apr 13, 2023
@findleyr findleyr self-assigned this Apr 13, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/484375 mentions this issue: Revert "go/types, types2: remove unnecessary tests for x.typ == Typ[Invalid]"

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/484376 mentions this issue: go/types,types2: add a test for const initializer panic

gopherbot pushed a commit that referenced this issue Apr 13, 2023
Updates #59603

Change-Id: Iff99f45a72a259b57b2ebbc6c0f9ed710add3ae3
Reviewed-on: https://go-review.googlesource.com/c/go/+/484376
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
@dmitshur dmitshur added the NeedsFix The path to resolution is known, but the work has not been done. label Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants