]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile, types2: better error message for invalid type assertion
authorRobert Griesemer <gri@golang.org>
Mon, 18 Oct 2021 21:56:08 +0000 (14:56 -0700)
committerRobert Griesemer <gri@golang.org>
Tue, 19 Oct 2021 17:01:35 +0000 (17:01 +0000)
commit254c497e5c5628be115b966808d6e76d335313a3
treea8b7fb206d30b0a9857ab1c845e692db4c240f04
parentf92a3589fa04285dccab3ca7454eaaf2d0e7cde3
cmd/compile, types2: better error message for invalid type assertion

This CL addresses the 2nd part of the issue below.

- For types2, now use the same error messages as the compiler in this case.
- Make the mechanism for reporting clarifying error messages handle the case
  where we don't have additional position information.
- Provide context information (type assertion vs type switch).

Fixes #49005.

Change-Id: I4eeaf4f0c3f2f8735b63993778f58d713fef21ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/356512
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/errors.go
src/cmd/compile/internal/types2/errors_test.go
src/cmd/compile/internal/types2/expr.go
src/cmd/compile/internal/types2/stmt.go
src/cmd/compile/internal/types2/testdata/check/expr3.src
src/cmd/compile/internal/types2/testdata/check/issues.src
src/cmd/compile/internal/types2/testdata/check/stmt0.src
src/cmd/compile/internal/types2/testdata/fixedbugs/issue49005.go [new file with mode: 0644]
test/fixedbugs/issue49005b.go [new file with mode: 0644]
test/switch6.go