]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: add additional test data from types2
authorRob Findley <rfindley@google.com>
Thu, 29 Apr 2021 15:42:35 +0000 (11:42 -0400)
committerRobert Findley <rfindley@google.com>
Thu, 29 Apr 2021 16:31:18 +0000 (16:31 +0000)
Add some test data files that were not included in go/types.

- Issue 43125 only pertained to types2 because go/ast differentiates
  StarExpr, UnaryExpr, and BinaryExpr, so typexpr.go was already
  catching the invalid type expressions.
- Issues 42987 and 43190 are handled differently by go/parser.
- main.go2 was not added when ported to go/types, because this work
  happened on the dev.regabi branch, which didn't support generics.

Test files are modified to adjust errors messages and positions, and to
update the copyright year.

Change-Id: Ia737eaab9afb2b59600b661ccf3eec3cbbb2d66c
Reviewed-on: https://go-review.googlesource.com/c/go/+/315070
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/types/testdata/check/main.go2 [new file with mode: 0644]
src/go/types/testdata/fixedbugs/issue42987.src [new file with mode: 0644]
src/go/types/testdata/fixedbugs/issue43125.src [new file with mode: 0644]
src/go/types/testdata/fixedbugs/issue43190.src [new file with mode: 0644]

diff --git a/src/go/types/testdata/check/main.go2 b/src/go/types/testdata/check/main.go2
new file mode 100644 (file)
index 0000000..65e9aa2
--- /dev/null
@@ -0,0 +1,7 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+func main[ /* ERROR "func main must have no type parameters" */ T any]() {}
diff --git a/src/go/types/testdata/fixedbugs/issue42987.src b/src/go/types/testdata/fixedbugs/issue42987.src
new file mode 100644 (file)
index 0000000..6060ec8
--- /dev/null
@@ -0,0 +1,10 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Check that there is only one error (no follow-on errors).
+
+package p
+// TODO(rFindley) This is a parser error, but in types2 it is a type checking
+//                error. We could probably do without this check in the parser.
+var _ = [... /* ERROR expected array length, found '...' */ ]byte("foo")
diff --git a/src/go/types/testdata/fixedbugs/issue43125.src b/src/go/types/testdata/fixedbugs/issue43125.src
new file mode 100644 (file)
index 0000000..456888d
--- /dev/null
@@ -0,0 +1,8 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+var _ = new(- /* ERROR not a type */ 1)
+var _ = new(1 /* ERROR not a type */ + 1)
diff --git a/src/go/types/testdata/fixedbugs/issue43190.src b/src/go/types/testdata/fixedbugs/issue43190.src
new file mode 100644 (file)
index 0000000..96acb3a
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Most of the errors below are actually produced by the parser, but we check
+// them here for consistency with the types2 tests.
+
+package p
+
+import ; /* ERROR invalid import path */ /* ERROR expected 'STRING' */
+import // ERROR expected ';'
+var _ int
+import /* ERROR expected declaration */ .;
+
+import ()
+import (.)
+import (
+       "fmt"
+       .
+)
+
+var _ = fmt /* ERROR "undeclared name" */ .Println