Commit 2ca99505 authored by Jan Ziak's avatar Jan Ziak

cmd/gc: suppress array index error caused by a previously reported error

Fixes #7153

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/82180043
parent 83ac901f
......@@ -2525,8 +2525,9 @@ typecheckcomplit(Node **np)
typecheck(&l->left, Erv);
evconst(l->left);
i = nonnegconst(l->left);
if(i < 0) {
if(i < 0 && !l->left->diag) {
yyerror("array index must be non-negative integer constant");
l->left->diag = 1;
i = -(1<<30); // stay negative for a while
}
if(i >= 0)
......
......@@ -9,6 +9,6 @@ package main
var x int
var a = []int{ x: 1} // ERROR "constant"
var b = [...]int{ x : 1} // ERROR "constant"
var b = [...]int{x: 1}
var c = map[int]int{ x: 1}
// errorcheck
// Copyright 2014 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.
// Issue 7153: array invalid index error duplicated on successive bad values
package p
var _ = []int{a: true, true} // ERROR "undefined: a" "cannot use true \(type bool\) as type int in array element"
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