package main

const foo = []int{1,2}

x.go:3: expression must be a constant

instead of

x.go:3: fatal error: gettype: addtop

R=ken
OCL=30767
CL=30767
This commit is contained in:
Russ Cox 2009-06-25 16:42:08 -07:00
parent 70a273476b
commit fa6df47986
1 changed files with 11 additions and 2 deletions

View File

@ -1684,7 +1684,7 @@ void
constiter(Node *vv, Type *t, Node *cc)
{
Iter viter, citer;
Node *v, *c;
Node *v, *c, n1;
if(cc == N) {
if(t != T)
@ -1712,7 +1712,16 @@ loop:
return;
}
gettype(c, N);
memset(&n1, 0, sizeof n1);
gettype(c, &n1);
if(n1.ninit != nil) {
// the expression had extra code to run.
// dodclconst is going to print an error
// because the expression isn't constant,
// but out of paranoia, bump nerrors so
// that compile cannot succeed accidentally
nerrors++;
}
if(t != T)
convlit(c, t);
if(t == T)