Skip to content

Commit 79a5fce

Browse files
committed
Add note that LEAVE phasers do get run
even when routine param binding fails
1 parent 2387ce3 commit 79a5fce

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

doc/Language/phasers.pod6

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,21 @@ that point.
272272
42 # this is the return value
273273
}
274274
275+
B<Note:> be mindful of C<LEAVE> phasers directly in blocks of routines, as
276+
they will get executed even when an attempt to call the routine with wrong
277+
arguments is made:
278+
279+
sub foo (Int) {
280+
say "Hello!";
281+
LEAVE say "oh noes!"
282+
}
283+
try foo rand; # OUTPUT: «oh noes!␤»
284+
285+
Although the subroutine's body did not get run, because the sub expects
286+
an L<Int> and L«C<rand>|/routine/rand» returned a L<Num>, its block was
287+
entered and left (when param binding failed), and so the C<LEAVE> phaser
288+
I<was> run.
289+
275290
=head2 X<KEEP|Phasers>
276291
277292
Runs at every successful block exit, as part of the LEAVE queue (shares the

0 commit comments

Comments
 (0)