diff --git a/src/cmd/gc/sinit.c b/src/cmd/gc/sinit.c index e0581e64ce7..e41d1158499 100644 --- a/src/cmd/gc/sinit.c +++ b/src/cmd/gc/sinit.c @@ -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; diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c index 31b52434a3e..a97ea72314c 100644 --- a/src/cmd/gc/walk.c +++ b/src/cmd/gc/walk.c @@ -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; diff --git a/test/fixedbugs/bug176.go b/test/fixedbugs/bug176.go new file mode 100644 index 00000000000..5820df30842 --- /dev/null +++ b/test/fixedbugs/bug176.go @@ -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} +