<!-- go.dev/issue/71517 -->
The message printed when a program exits due to an unhandled panic
-that was recovered and re-raised no longer repeats the text of
+that was recovered and repanicked no longer repeats the text of
the panic value.
Previously, a program which panicked with `panic("PANIC")`,
-recovered the panic, and then re-panicked with the original
+recovered the panic, and then repanicked with the original
value would print:
panic: PANIC [recovered]
This program will now print:
- panic: PANIC [recovered, reraised]
+ panic: PANIC [recovered, repanicked]
<!-- go.dev/issue/71546 -->
! go test -v cleanup_failnow/panic_nocleanup_test.go
! stdout 'no tests to run'
-stdout '(?s)panic: die \[recovered, reraised\]'
-! stdout '(?s)panic: die \[recovered, reraised\].*panic: die'
+stdout '(?s)panic: die \[recovered, repanicked\]'
+! stdout '(?s)panic: die \[recovered, repanicked\].*panic: die'
! go test -v cleanup_failnow/panic_withcleanup_test.go
! stdout 'no tests to run'
# Disable vet, as its "tests" analyzer would report the same problem statically.
! go test -vet=off .
-stdout '^panic: testing: fuzz target must not return a value \[recovered, reraised\]$'
+stdout '^panic: testing: fuzz target must not return a value \[recovered, repanicked\]$'
-- go.mod --
module test
}
-func TestReraisedPanic(t *testing.T) {
- output := runTestProg(t, "testprog", "ReraisedPanic")
- want := `panic: message [recovered, reraised]
+func TestRepanickedPanic(t *testing.T) {
+ output := runTestProg(t, "testprog", "RepanickedPanic")
+ want := `panic: message [recovered, repanicked]
`
if !strings.HasPrefix(output, want) {
t.Fatalf("output does not start with %q:\n%s", want, output)
}
}
-func TestReraisedMiddlePanic(t *testing.T) {
- output := runTestProg(t, "testprog", "ReraisedMiddlePanic")
+func TestRepanickedMiddlePanic(t *testing.T) {
+ output := runTestProg(t, "testprog", "RepanickedMiddlePanic")
want := `panic: inner [recovered]
- panic: middle [recovered, reraised]
+ panic: middle [recovered, repanicked]
panic: outer
`
if !strings.HasPrefix(output, want) {
}
}
-func TestReraisedPanicSandwich(t *testing.T) {
- output := runTestProg(t, "testprog", "ReraisedPanicSandwich")
+func TestRepanickedPanicSandwich(t *testing.T) {
+ output := runTestProg(t, "testprog", "RepanickedPanicSandwich")
want := `panic: outer [recovered]
panic: inner [recovered]
panic: outer
for p != nil {
if p.link != nil && *efaceOf(&p.link.arg) == *efaceOf(&p.arg) {
// This panic contains the same value as the next one in the chain.
- // Mark it as reraised. We will skip printing it twice in a row.
- p.link.reraised = true
+ // Mark it as repanicked. We will skip printing it twice in a row.
+ p.link.repanicked = true
p = p.link
continue
}
func printpanics(p *_panic) {
if p.link != nil {
printpanics(p.link)
- if p.link.reraised {
+ if p.link.repanicked {
return
}
if !p.link.goexit {
}
print("panic: ")
printpanicval(p.arg)
- if p.reraised {
- print(" [recovered, reraised]")
+ if p.repanicked {
+ print(" [recovered, repanicked]")
} else if p.recovered {
print(" [recovered]")
}
slotsPtr unsafe.Pointer
recovered bool // whether this panic has been recovered
- reraised bool // whether this panic was reraised
+ repanicked bool // whether this panic repanicked
goexit bool
deferreturn bool
}
register("StringPanic", StringPanic)
register("NilPanic", NilPanic)
register("CircularPanic", CircularPanic)
- register("ReraisedPanic", ReraisedPanic)
- register("ReraisedMiddlePanic", ReraisedMiddlePanic)
- register("ReraisedPanicSandwich", ReraisedPanicSandwich)
+ register("RepanickedPanic", RepanickedPanic)
+ register("RepanickedMiddlePanic", RepanickedMiddlePanic)
+ register("RepanickedPanicSandwich", RepanickedPanicSandwich)
}
func test(name string) {
panic(exampleCircleStartError{})
}
-func ReraisedPanic() {
+func RepanickedPanic() {
defer func() {
panic(recover())
}()
panic("message")
}
-func ReraisedMiddlePanic() {
+func RepanickedMiddlePanic() {
defer func() {
recover()
panic("outer")
// recovered, panic("inner") =>
// panic(recovered outer panic value)
//
-// Exercises the edge case where we reraise a panic value,
+// Exercises the edge case where we repanic a panic value,
// but with another panic in the middle.
-func ReraisedPanicSandwich() {
+func RepanickedPanicSandwich() {
var outer any
defer func() {
recover()