mirror of
https://github.com/golang/go
synced 2024-11-11 21:50:21 -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:
parent
37519d950d
commit
656b192c16
@ -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);
|
||||||
|
10
test/ddd1.go
10
test/ddd1.go
@ -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 }
|
||||||
|
Loading…
Reference in New Issue
Block a user