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: error message when comparing structs containing slices less helpful in go1.18 #50918

Closed
sarnesjo opened this issue Jan 31, 2022 · 2 comments
Labels
NeedsFix
Milestone

Comments

@sarnesjo
Copy link

@sarnesjo sarnesjo commented Jan 31, 2022

In Go, slices are not comparable using ==. The same is true for structs containing slices. (spec)

Using go1.17.6, this is reported with an error message that clearly states what is wrong:

./prog.go:13:7: invalid operation: a == b (struct containing []string cannot be compared)

Using go1.18-a5c0b19080, however, the error message is less helpful:

./prog.go:13:5: invalid operation: cannot compare a == b (operator == not defined on thing)

This can be reproduced on the Go Playground, by switching between "Go release" and "Go dev branch": https://go.dev/play/p/kvCNFuMZzOF

@ALTree ALTree changed the title go: error message when comparing structs containing slices less helpful in go1.18 cmd/compile: error message when comparing structs containing slices less helpful in go1.18 Jan 31, 2022
@ALTree
Copy link
Member

@ALTree ALTree commented Jan 31, 2022

Thanks for reporting this. The 1.17 error message is indeed quite better.

cc @griesemer

@ALTree ALTree added the NeedsInvestigation label Jan 31, 2022
@ALTree ALTree added this to the Go1.18 milestone Jan 31, 2022
@griesemer griesemer self-assigned this Jan 31, 2022
@griesemer griesemer added NeedsFix and removed NeedsInvestigation labels Feb 1, 2022
@gopherbot
Copy link

@gopherbot gopherbot commented Feb 1, 2022

Change https://golang.org/cl/381964 mentions this issue: cmd/compile/internal/types2: better error messages for comparisons

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix
Projects
None yet
Development

No branches or pull requests

4 participants