Skip to content

cmd/compile: spurious error for use of struct field with undefined type #54405

@rsc

Description

@rsc

Go 1.19 (and tip):

package p

var x struct{ f *NotAType }
var _ = x.f == nil

var y *NotAType
var _ = y == nil
./prog.go:3:18: undefined: NotAType
./prog.go:4:16: invalid operation: x.f == nil (operator == not defined on untyped nil)
./prog.go:6:8: undefined: NotAType

The second error, on line 4, should not be printed.
Note that there is no second error involving y.
Something about the struct field is confusing the matter.

https://go.dev/play/p/UQP8ZveEPVh

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions