Skip to content

Commit

Permalink
throw X::Phaser::Once exceptions when two CATCH or CONTROL blocks app…
Browse files Browse the repository at this point in the history
…ear in a block
  • Loading branch information
moritz committed Jan 23, 2012
1 parent d83a1c0 commit 00e5547
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Perl6/Actions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ class Perl6::Actions is HLL::Actions {

method statement_control:sym<CATCH>($/) {
if has_block_handler($*W.cur_lexpad(), 'CONTROL', :except(1)) {
$/.CURSOR.panic("only one CATCH block allowed");
$*W.throw($/, ['X', 'Phaser', 'Once'], block => p6box_s('CATCH'));
}
my $block := $<block>.ast;
push_block_handler($/, $*W.cur_lexpad(), $block, 'CONTROL', :except(1));
Expand All @@ -862,7 +862,7 @@ class Perl6::Actions is HLL::Actions {

method statement_control:sym<CONTROL>($/) {
if has_block_handler($*W.cur_lexpad(), 'CONTROL') {
$/.CURSOR.panic("only one CONTROL block allowed");
$*W.throw($/, ['X', 'Phaser', 'Once'], block => p6box_s('CONTROL'));
}
my $block := $<block>.ast;
push_block_handler($/, $*W.cur_lexpad(), $block, 'CONTROL');
Expand Down
5 changes: 5 additions & 0 deletions src/core/Exceptions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ my class X::Redeclaration is X::Base does X::Comp {
}
}

my class X::Phaser::Once is X::Base does X::Comp {
has $.block;
method message() { "Only one $.block block is allowed" }
}

my class X::Obsolete is X::Base does X::Comp {
has $.old;
has $.new;
Expand Down

0 comments on commit 00e5547

Please sign in to comment.