Hi

Am 2026-04-15 16:52, schrieb Larry Garfield:
The finally path is only reached in case of a successful exit. Therefore there is no exception to pass in, and thus returning an exception is meaningless. […]

That's not at all how I understood the RFC text (and I admittedly didn't look at the desugaring):

If exitContext() returns a throwable (either a new one or the one it was passed), it will be rethrown.

I understood the “it” in “it will be rethrown” as “the returned Throwable is thrown”, not “the Throwable that was caught is thrown”. That is also what is mentioned in your email https://news-web.php.net/php.internals/130413:

or a throwable, which will then get thrown

and

If there's a reason to wrap and rethrow the exception, do that and return the new exception

And that is what the second half of my email https://news-web.php.net/php.internals/130479 is based on, particularly the joke in the footnote. Why has this misunderstanding not been pointed out back then?

------------

So based on the desugaring that Rob thankfully looked at, of all the information in a `?\Throwable` return type, only a single bit is used - and only in some cases. I don't see how we can meaningfully explain to users that throwing away all the other information is the expected behavior.

Best regards
Tim Düsterhus

Reply via email to