# New Ticket Created by "Brian S. Julin"
# Please include the string: [perl #125769]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=125769 >
A newly created Failure can be prevented from sinking by assigning
it to a variable. Binding it to a variable also protects it from
being immediately sunk. However, when the latter happens as the last
statement in an if { ... }, the exception is sunk and thrown.
Expected behavior: The "bar" failure below should not throw.
$ cat /tmp/foo.pm6
sub a {
if (1) {
my $f = Failure.new("foo");
}
return 1;
}
my $a = a();
sub b {
if (1) {
my $f := Failure.new("bar");
}
return 1;
}
my $b = b();
42.say
$ perl6 /tmp/foo.pm6
bar
in sub b at /tmp/foo.pm6:10
in block <unit> at /tmp/foo.pm6:15
Actually thrown at:
in sub b at /tmp/foo.pm6:10
in block <unit> at /tmp/foo.pm6:15