Skip to content

Commit bc3cf28

Browse files
committed
go/loader: loosen a test assertion on go/types error messages
In CL 267717, the error message for invalid assignment of untyped values is being corrected from 'cannot convert ...' to 'cannot use ... as ... int ...'. This breaks the go/loader tests due to an assertion on the former message. Since the Go repo TryBots run x/tools tests, this assertion must be loosened to allow merging the CL above. Change-Id: I8a371397c9df58109090b7fd2eaa5b4a600776ef Reviewed-on: https://go-review.googlesource.com/c/tools/+/267686 Run-TryBot: Robert Findley <rfindley@google.com> Trust: Robert Findley <rfindley@google.com> Trust: Robert Griesemer <gri@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
1 parent 22bd852 commit bc3cf28

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

go/loader/loader_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,11 @@ func TestErrorReporting(t *testing.T) {
645645
for pkg, info := range prog.AllPackages {
646646
switch pkg.Path() {
647647
case "a":
648-
if !hasError(info.Errors, "cannot convert false") {
649-
t.Errorf("a.Errors = %v, want bool conversion (type) error", info.Errors)
648+
// The match below is unfortunately vague, because in go1.16 the error
649+
// message in go/types changed from "cannot convert ..." to "cannot use
650+
// ... as ... in assignment".
651+
if !hasError(info.Errors, "cannot") {
652+
t.Errorf("a.Errors = %v, want bool assignment (type) error", info.Errors)
650653
}
651654
if !hasError(info.Errors, "could not import c") {
652655
t.Errorf("a.Errors = %v, want import (loader) error", info.Errors)
@@ -659,7 +662,7 @@ func TestErrorReporting(t *testing.T) {
659662
}
660663

661664
// Check errors reported via error handler.
662-
if !hasError(allErrors, "cannot convert false") ||
665+
if !hasError(allErrors, "cannot") ||
663666
!hasError(allErrors, "rune literal not terminated") ||
664667
!hasError(allErrors, "could not import c") {
665668
t.Errorf("allErrors = %v, want syntax, type and loader errors", allErrors)

0 commit comments

Comments
 (0)