aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/testdata/check
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-07-09 19:03:48 -0700
committerRobert Griesemer <gri@golang.org>2021-07-14 23:33:47 +0000
commit95f8e64fc0ff53e4df6ba03e8dbbaf3d18695d1b (patch)
treec49788f5459175eb8a6de6a336ddcc384bc2cfcc /src/cmd/compile/internal/types2/testdata/check
parent5f0ea40c67839ae82b6018fe881f173f9b09d306 (diff)
downloadgo-95f8e64fc0ff53e4df6ba03e8dbbaf3d18695d1b.tar.gz
go-95f8e64fc0ff53e4df6ba03e8dbbaf3d18695d1b.zip
[dev.typeparams] cmd/compile/internal/types2: implement delete(m, k) where m is of type parameter type
Change-Id: Iaf33c15128af911b6101df9885cb8b5a8495b942 Reviewed-on: https://go-review.googlesource.com/c/go/+/333729 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/testdata/check')
-rw-r--r--src/cmd/compile/internal/types2/testdata/check/builtins.go237
1 files changed, 37 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/types2/testdata/check/builtins.go2 b/src/cmd/compile/internal/types2/testdata/check/builtins.go2
index 71295bf434..8fe6d7b332 100644
--- a/src/cmd/compile/internal/types2/testdata/check/builtins.go2
+++ b/src/cmd/compile/internal/types2/testdata/check/builtins.go2
@@ -43,6 +43,43 @@ func _[T C5[X], X any](ch T) {
close(ch)
}
+// delete
+
+type M0 interface{ int }
+type M1 interface{ map[string]int }
+type M2 interface { map[string]int | map[string]float64 }
+type M3 interface{ map[string]int | map[rune]int }
+type M4[K comparable, V any] interface{ map[K]V | map[rune]V }
+
+func _[T any](m T) {
+ delete(m /* ERROR not a map */, "foo")
+}
+
+func _[T M0](m T) {
+ delete(m /* ERROR not a map */, "foo")
+}
+
+func _[T M1](m T) {
+ delete(m, "foo")
+}
+
+func _[T M2](m T) {
+ delete(m, "foo")
+ delete(m, 0 /* ERROR cannot use .* as string */)
+}
+
+func _[T M3](m T) {
+ delete(m /* ERROR must have identical key types */, "foo")
+}
+
+func _[T M4[rune, V], V any](m T) {
+ delete(m, 'k')
+}
+
+func _[T M4[K, V], K comparable, V any](m T) {
+ delete(m /* ERROR must have identical key types */, "foo")
+}
+
// make
type Bmc interface {