testFiles = flag.String("files", "", "space-separated list of test files")
)
-func parseFiles(t *testing.T, filenames []string) ([]*syntax.File, []error) {
+func parseFiles(t *testing.T, filenames []string, mode syntax.Mode) ([]*syntax.File, []error) {
var files []*syntax.File
var errlist []error
errh := func(err error) { errlist = append(errlist, err) }
for _, filename := range filenames {
- file, err := syntax.ParseFile(filename, errh, nil, syntax.AllowGenerics)
+ file, err := syntax.ParseFile(filename, errh, nil, mode)
if file == nil {
t.Fatalf("%s: %s", filename, err)
}
}
func checkFiles(t *testing.T, sources []string, colDelta uint, trace bool) {
+ if len(sources) == 0 {
+ t.Fatal("no source files")
+ }
+
+ var mode syntax.Mode
+ if strings.HasSuffix(sources[0], ".go2") {
+ mode |= syntax.AllowGenerics
+ }
// parse files and collect parser errors
- files, errlist := parseFiles(t, sources)
+ files, errlist := parseFiles(t, sources, mode)
pkgName := "<no package>"
if len(files) > 0 {
return !isTyped(typ)
}
-func isOrdered(typ Type) bool { return is(typ, IsOrdered) }
-
-func isConstType(typ Type) bool {
- t := typ.Basic()
- return t != nil && t.info&IsConstType != 0
-}
+func isOrdered(typ Type) bool { return is(typ, IsOrdered) }
+func isConstType(typ Type) bool { return is(typ, IsConstType) }
// IsInterface reports whether typ is an interface type.
func IsInterface(typ Type) bool {
ms = "foo" /* ERROR "cannot use .* in assignment" */ [1:2]
ms = "foo" /* ERROR "cannot use .* in assignment" */ [i:j]
_, _ = ss, ms
-
- // With type parameters, index expressions may have multiple indices.
- _ = a[i, j /* ERROR "more than one index" */ ]
- _ = a[i, j /* ERROR "more than one index" */ , j]
}
type T struct {