Skip to content

Commit 656b192

Browse files
cmd/gc: reject use of ... with multiple-valued expressions.
Fixes golang#3334. R=golang-dev, r CC=golang-dev, remy https://golang.org/cl/6350103
1 parent 37519d9 commit 656b192

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/cmd/gc/typecheck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ typecheck1(Node **np, int top)
929929
goto doconv;
930930
}
931931

932-
if(count(n->list) == 1)
932+
if(count(n->list) == 1 && !n->isddd)
933933
typecheck(&n->list->n, Erv | Efnstruct);
934934
else
935935
typechecklist(n->list, Erv);

test/ddd1.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ var (
2222
_ = sum([]int{1}) // ERROR "\[\]int literal.*as type int|incompatible"
2323
)
2424

25+
func sum3(int, int, int) int { return 0 }
26+
func tuple() (int, int, int) { return 1, 2, 3 }
27+
28+
var (
29+
_ = sum(tuple())
30+
_ = sum(tuple()...) // ERROR "multiple-value"
31+
_ = sum3(tuple())
32+
_ = sum3(tuple()...) // ERROR "multiple-value" "not enough"
33+
)
34+
2535
type T []T
2636

2737
func funny(args ...T) int { return 0 }

0 commit comments

Comments
 (0)