]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: reject use of ... with multiple-valued expressions.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Fri, 13 Jul 2012 06:05:41 +0000 (08:05 +0200)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Fri, 13 Jul 2012 06:05:41 +0000 (08:05 +0200)
Fixes #3334.

R=golang-dev, r
CC=golang-dev, remy
https://golang.org/cl/6350103

src/cmd/gc/typecheck.c
test/ddd1.go

index cc4faf5a7a851f3e87e27ee042dc7fae99f29344..0335fe0c3264da951f5c059ab03790b9e15149d4 100644 (file)
@@ -929,7 +929,7 @@ reswitch:
                        goto doconv;
                }
 
-               if(count(n->list) == 1)
+               if(count(n->list) == 1 && !n->isddd)
                        typecheck(&n->list->n, Erv | Efnstruct);
                else
                        typechecklist(n->list, Erv);
index 1e070093c3fbd11af25f494c0ff4df628d26d6db..09d70c3de3cd07f7914bb4ddc0834e888b27add2 100644 (file)
@@ -22,6 +22,16 @@ var (
        _ = 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
 
 func funny(args ...T) int { return 0 }