]> Cypherpunks repositories - gostls13.git/commit
go/types, types2: report type mismatch error when conversion is impossible
authorRobert Griesemer <gri@golang.org>
Mon, 12 Dec 2022 21:36:44 +0000 (13:36 -0800)
committerRobert Griesemer <gri@google.com>
Tue, 13 Dec 2022 16:52:44 +0000 (16:52 +0000)
commit5ba98b975638323acf733438a619e9190dfa8afa
tree855751be525bac17bcd5c52125a4b5a1f75ff490
parent61e2b8ec598e33b0d55a0652f86eeb075de3dc9d
go/types, types2: report type mismatch error when conversion is impossible

Rather than reporting an impossible conversion error when mixing an
untyped value with a pointer type in an operation, report a type
mismatch error. This fixes a regression in error quality compared
to pre-1.18.

For the fix, clean up the implementation of canMix, add documentation,
and give it a better name.

Adjust test case for corresponding error code bacause we now get a
better error message (and error code) for the old error code example.

Fixes #57160.

Change-Id: Ib96ce7cbc44db6905fa2f1c90a3769af609e101b
Reviewed-on: https://go-review.googlesource.com/c/go/+/457055
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
src/cmd/compile/internal/types2/expr.go
src/go/types/expr.go
src/internal/types/errors/codes.go
src/internal/types/testdata/fixedbugs/issue57160.go [new file with mode: 0644]