Commit 18840f54 authored by Russ Cox's avatar Russ Cox

constant keys for array initializers

R=ken
OCL=32261
CL=32261
parent 75760a4b
......@@ -458,6 +458,9 @@ initfix(NodeList *l)
if(0)
return xxx.list;
if(nerrors != 0)
return xxx.list;
// look for the copy-out reference
for(l=xxx.list; l; l=l->next) {
r = l->n;
......
......@@ -4534,7 +4534,7 @@ arraylit(Node *n, Node *var, NodeList **init)
if(r->op == OKEY) {
b = nonnegconst(r->left);
if(b < 0) {
yyerror("array index must be non-negative integer");
yyerror("array index must be non-negative constant");
break;
}
r = r->right;
......
// errchk $G $D/$F.go
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
var x int
var a = []int{ x: 1} // ERROR "constant"
var b = [...]int{ x : 1} // ERROR "constant"
var c = map[int]int{ x: 1}
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