1
0
mirror of https://github.com/golang/go synced 2024-11-25 03:57:56 -07:00

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

Fixes #3334.

R=golang-dev, r
CC=golang-dev, remy
https://golang.org/cl/6350103
This commit is contained in:
Rémy Oudompheng 2012-07-13 08:05:41 +02:00
parent 37519d950d
commit 656b192c16
2 changed files with 11 additions and 1 deletions

View File

@ -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);

View File

@ -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 }