Commit fa6df479 authored by Russ Cox's avatar Russ Cox

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
parent 70a27347
...@@ -1684,7 +1684,7 @@ void ...@@ -1684,7 +1684,7 @@ void
constiter(Node *vv, Type *t, Node *cc) constiter(Node *vv, Type *t, Node *cc)
{ {
Iter viter, citer; Iter viter, citer;
Node *v, *c; Node *v, *c, n1;
if(cc == N) { if(cc == N) {
if(t != T) if(t != T)
...@@ -1712,7 +1712,16 @@ loop: ...@@ -1712,7 +1712,16 @@ loop:
return; 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) if(t != T)
convlit(c, t); convlit(c, t);
if(t == T) if(t == T)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment