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
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@sarnesjo
Copy link

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 commented Jan 31, 2022

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

cc @griesemer

@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. 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 The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Feb 1, 2022
@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants