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

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

Closed
rsc opened this issue Aug 12, 2022 · 2 comments
Closed

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

rsc opened this issue Aug 12, 2022 · 2 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Aug 12, 2022

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

@rsc rsc added NeedsFix The path to resolution is known, but the work has not been done. compiler/runtime Issues related to the Go compiler and/or runtime. labels Aug 12, 2022
@rsc rsc added this to the Go1.20 milestone Aug 12, 2022
@gopherbot
Copy link

gopherbot commented Aug 12, 2022

Change https://go.dev/cl/423234 mentions this issue: cmd/compile: skip doing comparison for invalid types

@cuonglm cuonglm self-assigned this Aug 12, 2022
@gopherbot
Copy link

gopherbot commented Aug 15, 2022

Change https://go.dev/cl/424054 mentions this issue: go/types, types2: skip comparison for operands with invalid types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. 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