Commit 656b192c authored by Rémy Oudompheng's avatar Rémy Oudompheng

cmd/gc: reject use of ... with multiple-valued expressions.

Fixes #3334.

R=golang-dev, r
CC=golang-dev, remy
https://golang.org/cl/6350103
parent 37519d95
...@@ -929,7 +929,7 @@ reswitch: ...@@ -929,7 +929,7 @@ reswitch:
goto doconv; goto doconv;
} }
if(count(n->list) == 1) if(count(n->list) == 1 && !n->isddd)
typecheck(&n->list->n, Erv | Efnstruct); typecheck(&n->list->n, Erv | Efnstruct);
else else
typechecklist(n->list, Erv); typechecklist(n->list, Erv);
......
...@@ -22,6 +22,16 @@ var ( ...@@ -22,6 +22,16 @@ var (
_ = sum([]int{1}) // ERROR "\[\]int literal.*as type int|incompatible" _ = sum([]int{1}) // ERROR "\[\]int literal.*as type int|incompatible"
) )
func sum3(int, int, int) int { return 0 }
func tuple() (int, int, int) { return 1, 2, 3 }
var (
_ = sum(tuple())
_ = sum(tuple()...) // ERROR "multiple-value"
_ = sum3(tuple())
_ = sum3(tuple()...) // ERROR "multiple-value" "not enough"
)
type T []T type T []T
func funny(args ...T) int { return 0 } func funny(args ...T) int { return 0 }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment