Skip to content

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

@findleyr

Description

@findleyr

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

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions