blob: 05e8d75514f8afda16c21f805f0acaecc6d293e2 [file] [log] [blame]
Rick Arnold8eec4eb2014-02-19 11:29:36 -08001// errorcheck
2
3// Copyright 2014 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7// issue 7150: array index out of bounds error off by one
8
9package main
10
11func main() {
Robert Griesemerc7a340312015-11-24 17:48:52 -080012 _ = [0]int{-1: 50} // ERROR "index must be non-negative integer constant"
13 _ = [0]int{0: 0} // ERROR "index 0 out of bounds \[0:0\]"
14 _ = [0]int{5: 25} // ERROR "index 5 out of bounds \[0:0\]"
15 _ = [10]int{2: 10, 15: 30} // ERROR "index 15 out of bounds \[0:10\]"
16 _ = [10]int{5: 5, 1: 1, 12: 12} // ERROR "index 12 out of bounds \[0:10\]"
Rick Arnold8eec4eb2014-02-19 11:29:36 -080017}