-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Closed
Labels
FrozenDueToAgeLanguageChangeSuggested changes to the Go languageSuggested changes to the Go languageNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.ProposalProposal-Acceptedv2An incompatible library changeAn incompatible library change
Milestone
Description
Calling panic with a nil panic value is allowed in Go 1, but weird.
Almost all code checks for panics with:
defer func() {
if e := recover(); e != nil { ... }
}()... which is not correct in the case of panic(nil).
The proper way is more like:
panicked := true
defer func() {
if panicked {
e := recover()
...
}
}()
...
panicked = false
return
....
panicked = false
returnProposal: make the runtime panic function promote its panic value from nil to something like a runtime.NilPanic global value of private, unassignable type:
package runtime
type nilPanic struct{}
// NilPanic is the value returned by recover when code panics with a nil value.
var NilPanic nilPanicProbably Go2.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeLanguageChangeSuggested changes to the Go languageSuggested changes to the Go languageNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.ProposalProposal-Acceptedv2An incompatible library changeAn incompatible library change