Skip to content

Commit 5b62ba1

Browse files
alityrsc
authored andcommitted
gc: disallow ... in type conversions
Fixes golang#1866. R=bradfitz, rsc CC=golang-dev https://golang.org/cl/4548073
1 parent c72dbaf commit 5b62ba1

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/cmd/gc/typecheck.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ typecheck(Node **np, int top)
794794
defaultlit(&n->left, T);
795795
l = n->left;
796796
if(l->op == OTYPE) {
797-
if(n->isddd)
797+
if(n->isddd || l->type->bound == -100)
798798
yyerror("invalid use of ... in type conversion", l);
799799
// pick off before type-checking arguments
800800
ok |= Erv;

test/ddd1.go

+1
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ func bad(args ...int) {
4343
var x int
4444
_ = unsafe.Pointer(&x...) // ERROR "[.][.][.]"
4545
_ = unsafe.Sizeof(x...) // ERROR "[.][.][.]"
46+
_ = [...]byte("foo") // ERROR "[.][.][.]"
4647
}

0 commit comments

Comments
 (0)