mirror of
https://github.com/golang/go
synced 2024-09-04 23:44:16 +00:00
![Keith Randall](/assets/img/avatar_default.png)
type A [0]int var a A x := a[i] Use the zero value for x instead of the "impossible" value. That lets us at least compile code like this with -B, even though it can't possibly run correctly. Fixes #48092 Change-Id: Idad5cfab49e05f375c069b05addceed68a15299f Reviewed-on: https://go-review.googlesource.com/c/go/+/346589 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org>
18 lines
413 B
Go
18 lines
413 B
Go
// compile -B
|
|
|
|
// Copyright 2021 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.
|
|
|
|
// Make sure that we can at least compile this code
|
|
// successfully with -B. We can't ever produce the right
|
|
// answer at runtime with -B, as the access must panic.
|
|
|
|
package p
|
|
|
|
type A [0]byte
|
|
|
|
func (a *A) Get(i int) byte {
|
|
return a[i]
|
|
}
|