Skip to content

Commit

Permalink
return without any arguments should not be an error, but rather just …
Browse files Browse the repository at this point in the history
…return Nil.
  • Loading branch information
jnthn committed Feb 9, 2010
1 parent f456c24 commit 057d093
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Perl6/Actions.pm
Expand Up @@ -335,7 +335,8 @@ method statement_control:sym<use>($/) {
}

method statement_control:sym<return>($/) {
make PAST::Op.new( $<EXPR>.ast, :pasttype('return'), :node($/) );
my $retval := $<EXPR> ?? $<EXPR>[0].ast !! PAST::Op.new( :name('&Nil') );
make PAST::Op.new( $retval, :pasttype('return'), :node($/) );
}

method statement_control:sym<given>($/) {
Expand Down
3 changes: 1 addition & 2 deletions src/Perl6/Grammar.pm
Expand Up @@ -366,8 +366,7 @@ token statement_control:sym<loop> {
}

token statement_control:sym<return> {
<sym> :s
[ <EXPR> || <.panic: 'return requires an expression argument'> ]
<sym> :s <EXPR>?
}

token statement_control:sym<use> {
Expand Down

0 comments on commit 057d093

Please sign in to comment.