Documentation for phasers LEAVE, assembled from the following types:
Runs at every block exit time (even stack unwinds from exceptions), except when the program exits abruptly (e.g. with
LEAVE phasers for a given block are necessarily evaluated after any
CONTROL phasers. This includes the
POST phasers are evaluated after everything else, to guarantee that even
LEAVE phasers can't violate postconditions.
An exception thrown from an
ENTER phaser will abort the
ENTER queue, but one thrown from a
LEAVE phaser will not.
POST fails or any kind of
LEAVE block throws an exception while the stack is unwinding, the unwinding continues and collects exceptions to be handled. When the unwinding is completed all new exceptions are thrown from that point.
Note: be mindful of
LEAVE phasers directly in blocks of routines, as they will get executed even when an attempt to call the routine with wrong arguments is made:
sub foo (Int)try foo rand; # OUTPUT: «oh noes!␤»