summaryrefslogtreecommitdiffstats
path: root/test/typeparam/issue376214.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/typeparam/issue376214.go')
-rw-r--r--test/typeparam/issue376214.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/typeparam/issue376214.go b/test/typeparam/issue376214.go
new file mode 100644
index 0000000..269b684
--- /dev/null
+++ b/test/typeparam/issue376214.go
@@ -0,0 +1,20 @@
+// run
+
+// 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 main
+
+func add[S ~string | ~[]byte](buf *[]byte, s S) {
+ *buf = append(*buf, s...)
+}
+
+func main() {
+ var buf []byte
+ add(&buf, "foo")
+ add(&buf, []byte("bar"))
+ if string(buf) != "foobar" {
+ panic("got " + string(buf))
+ }
+}