Skip to content

Commit

Permalink
Initial fix to allow fail() to work in subs with return type constrai…
Browse files Browse the repository at this point in the history
…nts. Will need review when we handle lower-cased types, or maybe if we can move ACCEPTS from P6object into Rakudo now after the release and tweak it to do the right thing. Anyway, it's a working solution for now.
  • Loading branch information
jnthn committed Aug 19, 2009
1 parent 352acd2 commit 0bc70da
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/parser/actions.pm
Expand Up @@ -3195,14 +3195,23 @@ sub return_handler_past() {
PAST::Var.new( :name('exception'), :scope('register') )
),
PAST::Op.new(
:pasttype('call'),
:name('die'),
:pasttype('if'),
PAST::Op.new( :inline(" $I0 = isa exception, 'Failure'",
" %r = box $I0") ),
PAST::Op.new(
:inline(' .return (%0)'),
PAST::Var.new( :name('exception'), :scope('register') )
),
PAST::Op.new(
:pasttype('call'),
:name('!make_type_fail_message'),
'Return value',
PAST::Var.new( :name('exception'), :scope('register') ),
PAST::Var.new( :name('$P0'), :scope('register') )
:name('die'),
PAST::Op.new(
:pasttype('call'),
:name('!make_type_fail_message'),
'Return value',
PAST::Var.new( :name('exception'), :scope('register') ),
PAST::Var.new( :name('$P0'), :scope('register') )
)
)
)
)
Expand Down

0 comments on commit 0bc70da

Please sign in to comment.