]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: better error message for invalid untyped nil conversion
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 5 Oct 2021 15:59:49 +0000 (22:59 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Thu, 7 Oct 2021 14:37:36 +0000 (14:37 +0000)
commit375a1fba0eb733676698ac3a9fdd12e6a8dd6602
treeb2f3bb442f025d9e6b7df58d2d73508bb7663e5c
parentecb2f231fa41b581319505139f8d5ac779763bee
cmd/compile: better error message for invalid untyped nil conversion

In case of an invalid untyped nil conversion, the compiler's original
type checker leaves it to the caller to report a suitable error message.
But types2 does not, it always reports the invalid conversion.

CL 328053 made types2 report a better error message, and match the
original compiler behavior. But it ignored the case of untyped nil.

This CL adds that missing case, by checking whether the two operands can
be mixed when untyped nil is present.

Fixes #48784

Change-Id: Idc7d86eb0245aa18ca428e278f4416d6b3679058
Reviewed-on: https://go-review.googlesource.com/c/go/+/354049
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
src/cmd/compile/internal/types2/expr.go
src/cmd/compile/internal/types2/testdata/check/expr2.src
test/fixedbugs/issue48784.go [new file with mode: 0644]