]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: permit f(nil...) for variadic arguments
authorAlan Donovan <adonovan@google.com>
Fri, 9 Dec 2016 14:55:50 +0000 (09:55 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 7 Feb 2017 14:09:32 +0000 (14:09 +0000)
This code may be pointless, but it is legal.

Fixes golang/go#18268

Change-Id: Ibacae583606e1a6fdf0c0f01abe2e22e9e608393
Reviewed-on: https://go-review.googlesource.com/34194
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/types/call.go
src/go/types/testdata/builtins.src

index 7f5823c8295c1aba77f26df51a92e2d4f656994c..7c54baa67acc4b8102a97ff2d5f6e8e27eb61dd2 100644 (file)
@@ -250,7 +250,7 @@ func (check *Checker) argument(fun ast.Expr, sig *Signature, i int, x *operand,
                        check.errorf(ellipsis, "can only use ... with matching parameter")
                        return
                }
-               if _, ok := x.typ.Underlying().(*Slice); !ok {
+               if _, ok := x.typ.Underlying().(*Slice); !ok && x.typ != Typ[UntypedNil] { // see issue #18268
                        check.errorf(x.pos(), "cannot use %s as parameter of type %s", x, typ)
                        return
                }
index 7fb7b58a48d904cd7f4f5a0413b557327930df4e..ecdba51553ecdcfb08c59eeac5f258d000789293 100644 (file)
@@ -19,6 +19,7 @@ func append1() {
        _ = append(nil /* ERROR not a slice */ , s)
        _ = append(x /* ERROR not a slice */ , s)
        _ = append(s)
+       _ = append(s, nil...)
        append /* ERROR not used */ (s)
 
        _ = append(s, b)