aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/testdata/fixedbugs
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-07-02 15:41:28 -0700
committerRobert Griesemer <gri@golang.org>2021-07-07 23:42:12 +0000
commit03ec8de24b6fc8a2abeb4013ef603f5cdef9f874 (patch)
tree0522ea7572f66479f5e672ef30ea2f112438a09b /src/cmd/compile/internal/types2/testdata/fixedbugs
parent47547d8508ab416e28992e0e0965c9c25f840848 (diff)
downloadgo-03ec8de24b6fc8a2abeb4013ef603f5cdef9f874.tar.gz
go-03ec8de24b6fc8a2abeb4013ef603f5cdef9f874.zip
[dev.typeparams] cmd/compile/internal/types2: clean up index expr implementation for type parameters
This makes the implementation match the intended spec behavior: Given an index expression a[x] where a is a type parameter, the index expression is valid if the constraint for a satisfies the following criteria: - Either all types in the constraint type set are maps, or none of them are. - If the (type set) types are maps, they must all have the same key type. (This may be too strict, perhaps it's sufficient to ensure assignability, but we can always relax that later.) - All (type set) types must have the same element types. - If there are any arrays, a constant index must be in range for the shortest array. Change-Id: I8c094c11e6fc9496c293871ccf93e3814c881e6f Reviewed-on: https://go-review.googlesource.com/c/go/+/332553 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/testdata/fixedbugs')
-rw-r--r--src/cmd/compile/internal/types2/testdata/fixedbugs/issue45635.go25
1 files changed, 2 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45635.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45635.go2
index e9b57ae8f1..2937959105 100644
--- a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45635.go2
+++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45635.go2
@@ -13,7 +13,7 @@ type N[T any] struct{}
var _ N[] /* ERROR expecting type */
type I interface {
- ~map[int]int | ~[]int
+ ~[]int
}
func _[T I](i, j int) {
@@ -27,6 +27,5 @@ func _[T I](i, j int) {
_ = s[i, j /* ERROR more than one index */ ]
var t T
- // TODO(gri) fix multiple error below
- _ = t[i, j /* ERROR more than one index */ /* ERROR more than one index */ ]
+ _ = t[i, j /* ERROR more than one index */ ]
}