Skip to content

Commit

Permalink
try {} should not catch control exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
tene committed Dec 16, 2009
1 parent 0307c29 commit 8a7d1c5
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/Perl6/Actions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -381,23 +381,28 @@ method statement_prefix:sym<gather>($/) {
method statement_prefix:sym<try>($/) {
my $block := $<blorst>.ast;
$block.blocktype('immediate');
my $past := PAST::Op.new( :pasttype('try'), $block );

# On failure, capture the exception object into $!.
$past.push(PAST::Op.new(
:inline( ' .get_results (%r)',
' $P0 = new ["Perl6Exception"]',
' setattribute $P0, "$!exception", %r',
' store_lex "$!", $P0' )
));
unless $block.handlers() {
$block.handlers([]);
}
$block.handlers().push(
PAST::Control.new(
:handle_types_except('CONTROL'),
PAST::Op.new(
:inline( ' .get_results (%r)',
' $P0 = new ["Perl6Exception"]',
' setattribute $P0, "$!exception", %r',
' store_lex "$!", $P0' )
),
)
);

# Otherwise, put a failure into $!.
$past.push(PAST::Op.new( :pasttype('bind'),
$block.push(PAST::Op.new( :pasttype('bind'),
PAST::Var.new( :name('$!'), :scope('lexical') ),
PAST::Op.new( :pasttype('call'), :name('!FAIL') )
));

make $past;
make $block;
}

method blorst($/) {
Expand Down

0 comments on commit 8a7d1c5

Please sign in to comment.