1
0
mirror of https://github.com/golang/go synced 2024-11-26 07:47:57 -07:00

go/types: add additional test data from types2

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>
This commit is contained in:
Rob Findley 2021-04-29 11:42:35 -04:00 committed by Robert Findley
parent f7c6f6210b
commit 5a8435d701
4 changed files with 47 additions and 0 deletions

7
src/go/types/testdata/check/main.go2 vendored Normal file
View File

@ -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]() {}

View File

@ -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")

View File

@ -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)

View File

@ -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