github.com/huandu/go@v0.0.0-20151114150818-04e615e41150/test/fixedbugs/issue7150.go (about)

     1  // 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  
     9  package main
    10  
    11  func main() {
    12  	_ = [0]int{-1: 50}              // ERROR "array index must be non-negative integer constant"
    13  	_ = [0]int{0: 0}                // ERROR "array index 0 out of bounds \[0:0\]"
    14  	_ = [0]int{5: 25}               // ERROR "array index 5 out of bounds \[0:0\]"
    15  	_ = [10]int{2: 10, 15: 30}      // ERROR "array index 15 out of bounds \[0:10\]"
    16  	_ = [10]int{5: 5, 1: 1, 12: 12} // ERROR "array index 12 out of bounds \[0:10\]"
    17  }