mirror of
https://github.com/golang/go
synced 2024-11-15 03:50:33 -07:00
3de175f383
Local facts can get us to unsatisfiable because there is an unconditional panic in the block. That shouldn't declare the whole block as unreachable, because we do still need to enter it to get that panic. Fixes #68816 Change-Id: I9220edb46089690702d2eb61d112815c7ac91f16 Reviewed-on: https://go-review.googlesource.com/c/go/+/604118 Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Keith Randall <khr@golang.org>
42 lines
566 B
Go
42 lines
566 B
Go
// run
|
|
|
|
// Copyright 2024 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.
|
|
|
|
package main
|
|
|
|
func main() {
|
|
mustPanic(func() {
|
|
f1(1)
|
|
})
|
|
f2(1, 0) // must not panic
|
|
mustPanic(func() {
|
|
f2(1, 2)
|
|
})
|
|
}
|
|
|
|
var v []func()
|
|
|
|
//go:noinline
|
|
func f1(i int) {
|
|
v = make([]func(), -2|i)
|
|
}
|
|
|
|
//go:noinline
|
|
func f2(i, j int) {
|
|
if j > 0 {
|
|
v = make([]func(), -2|i)
|
|
}
|
|
}
|
|
|
|
func mustPanic(f func()) {
|
|
defer func() {
|
|
r := recover()
|
|
if r == nil {
|
|
panic("didn't panic")
|
|
}
|
|
}()
|
|
f()
|
|
}
|