mirror of
https://github.com/golang/go
synced 2024-11-25 03:07:56 -07:00
constant keys for array initializers
R=ken OCL=32261 CL=32261
This commit is contained in:
parent
75760a4b5d
commit
18840f5429
@ -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;
|
||||
|
14
test/fixedbugs/bug176.go
Normal file
14
test/fixedbugs/bug176.go
Normal file
@ -0,0 +1,14 @@
|
||||
// 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}
|
||||
|
Loading…
Reference in New Issue
Block a user