diff options
| author | Robert Griesemer <gri@golang.org> | 2022-04-18 17:19:47 -0700 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2022-04-19 23:20:11 +0000 |
| commit | 86fa2551fb12338405721089d6db1b9d78e4f05e (patch) | |
| tree | 82f0b85c290391aeb9f7c9a7d77cbb4437aeb620 /src/cmd/compile/internal/syntax/testdata | |
| parent | 3ae414c31e59c9ee210fa3606f36cf0ea36b9906 (diff) | |
| download | go-86fa2551fb12338405721089d6db1b9d78e4f05e.tar.xz | |
cmd/compile/internal/types2: permit parentheses around types in interfaces
Before Go 1.18, an embedded type name in an interface could not be
parenthesized. With generalized embedding of types in interfaces,
where one might write ~(chan<- int) for clarity (making clear that
the ~ applies to the entire channel type), it also makes sense to
permit (chan<- int), or (int) for that matter.
Adjust the parser accordingly to match the spec.
(go/types already accepts the notation as specified by the spec.)
Fixes #52391.
Change-Id: Ifdd9a199c5ccc3473b2dac40dbca31d2df10d12b
Reviewed-on: https://go-review.googlesource.com/c/go/+/400797
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Diffstat (limited to 'src/cmd/compile/internal/syntax/testdata')
| -rw-r--r-- | src/cmd/compile/internal/syntax/testdata/issue52391.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/syntax/testdata/issue52391.go b/src/cmd/compile/internal/syntax/testdata/issue52391.go new file mode 100644 index 0000000000..f2098ceadb --- /dev/null +++ b/src/cmd/compile/internal/syntax/testdata/issue52391.go @@ -0,0 +1,17 @@ +// Copyright 2022 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 + +type _ interface { + int + (int) + (*int) + *([]byte) + ~(int) + (int) | (string) + (int) | ~(string) + (/* ERROR unexpected ~ */ ~int) + (int /* ERROR unexpected \| */ | /* ERROR unexpected string */ string /* ERROR unexpected \) */ ) +} |
