Catch rogue returns in top-level
This commit is contained in:
parent
8bdc8232f9
commit
f50550f882
1 changed files with 16 additions and 3 deletions
|
@ -428,7 +428,20 @@ sub parser_prog {
|
|||
return sub {
|
||||
my $ctx = shift;
|
||||
my $result;
|
||||
eval {
|
||||
$result = $_->($ctx) foreach (@steps);
|
||||
};
|
||||
if ($@)
|
||||
{
|
||||
if(my $type = ref($@))
|
||||
{
|
||||
if($type =~ /^return::(.*)$/)
|
||||
{
|
||||
die "return from block $1 outside of any block named $1";
|
||||
}
|
||||
}
|
||||
die "$@";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
@ -545,7 +558,7 @@ sub create_block {
|
|||
|
||||
if ($@)
|
||||
{
|
||||
if (ref($@) eq "BLOCK::$blockname")
|
||||
if (ref($@) eq "return::$blockname")
|
||||
{
|
||||
return $@->{retval};
|
||||
}
|
||||
|
@ -563,7 +576,7 @@ sub return_from_block {
|
|||
my $blockname = shift;
|
||||
my $retval = shift;
|
||||
|
||||
die bless({ retval => $retval }, "BLOCK::$blockname");
|
||||
die bless({ retval => $retval }, "return::$blockname");
|
||||
}
|
||||
|
||||
sub gen_macro_let {
|
||||
|
|
Loading…
Reference in a new issue