cmd/compile,wiki: clarify whether or not the panics created in loop bodies should propagate to function iterators #71830
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
Documentation
Issues describing a change to documentation.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
By the current doc, the loop body is viewed as being directly nested both in the innermost nesting function of the loop and in the
yield
function which is called in the iterator function.In my opinion, the loop body should be only viewed as directly nested both in the innermost nesting function of the loop.
In other words, when a function is used as an iterator, the
yield
calls should viewed as being removed from the iterator function.The effect of the doc change is that panics created in loop body are not catch-able in the iterator function.
(Another explanation: the panics created in loop bodies don't propagate to iterator functions.)
For example, the following two programs should have the same behavior, but they don't in 1.24.0 implementation. This is weird to users. By adopting the above explanations, then their behavior will become the same (the two
recover
calls should be both no-op).The text was updated successfully, but these errors were encountered: