Source file test/fixedbugs/issue77868.go

     1  // compile
     2  
     3  // Copyright 2026 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  package p
     8  
     9  type S struct {
    10  	n int
    11  	a [2]int
    12  }
    13  
    14  func f(i int) int {
    15  	var arr [0]S
    16  
    17  	// Accessing a zero-length array must not trigger an internal compiler error.
    18  	// This code is invalid, but make sure that we can compile it.
    19  	return arr[i].n
    20  }
    21  

View as plain text