]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/compile/internal/types2: process errors in src order during testing
authorRobert Griesemer <gri@golang.org>
Mon, 5 Apr 2021 23:06:18 +0000 (16:06 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 7 Apr 2021 05:19:36 +0000 (05:19 +0000)
Follow-up on https://golang.org/cl/305573.
As a consequence, re-enable test case that caused problems with that CL.

Change-Id: Ibffee3f016f4885a55b8e527a5680dd437322209
Reviewed-on: https://go-review.googlesource.com/c/go/+/307216
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/check_test.go
src/cmd/compile/internal/types2/fixedbugs/issue39634.go2

index 2418c29a2fbcaaeeefdff4e70507184f91affa85..331f0c7105a73a19a626467a295f7624d73ec7ce 100644 (file)
@@ -32,6 +32,7 @@ import (
        "os"
        "path/filepath"
        "regexp"
+       "sort"
        "strings"
        "testing"
 
@@ -150,6 +151,13 @@ func checkFiles(t *testing.T, filenames []string, goVersion string, colDelta uin
                return
        }
 
+       // sort errlist in source order
+       sort.Slice(errlist, func(i, j int) bool {
+               pi := unpackError(errlist[i]).Pos
+               pj := unpackError(errlist[j]).Pos
+               return pi.Cmp(pj) < 0
+       })
+
        // collect expected errors
        errmap := make(map[string]map[uint][]syntax.Error)
        for _, filename := range filenames {
@@ -165,7 +173,6 @@ func checkFiles(t *testing.T, filenames []string, goVersion string, colDelta uin
        }
 
        // match against found errors
-       // TODO(gri) sort err list to avoid mismatched when having multiple errors
        for _, err := range errlist {
                got := unpackError(err)
 
@@ -205,9 +212,8 @@ func checkFiles(t *testing.T, filenames []string, goVersion string, colDelta uin
 
                // eliminate from list
                if n := len(list) - 1; n > 0 {
-                       // not the last entry - swap in last element and shorten list by 1
-                       // TODO(gri) avoid changing the order of entries
-                       list[index] = list[n]
+                       // not the last entry - slide entries down (don't reorder)
+                       copy(list[index:], list[index+1:])
                        filemap[line] = list[:n]
                } else {
                        // last entry - remove list from filemap
index c99903f39991f1200c1c8118a3a649be45f8582c..36ad1ba08a5258f35aa563ad027947ed9fecf16b 100644 (file)
@@ -41,8 +41,7 @@ type foo9[A any] interface { type foo9 /* ERROR interface contains type constrai
 func _() { var _ = new(foo9 /* ERROR interface contains type constraints */ [int]) }
 
 // crash 12
-// TODO(gri) temporarily disabled due to an error check issue
-// var u /* ERROR cycle */ , i [func /* ERROR used as value */ /* ERROR used as value */ (u, c /* ERROR undeclared */ /* ERROR undeclared */ ) {}(0, len)]c /* ERROR undeclared */ /* ERROR undeclared */
+var u /* ERROR cycle */ , i [func /* ERROR used as value */ /* ERROR used as value */ (u, c /* ERROR undeclared */ /* ERROR undeclared */ ) {}(0, len /* ERROR must be called */ /* ERROR must be called */ )]c /* ERROR undeclared */ /* ERROR undeclared */
 
 // crash 15
 func y15() { var a /* ERROR declared but not used */ interface{ p() } = G15[string]{} }