Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Allow leading & on subroutine declarations.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Dec 2, 2009
1 parent cd02597 commit 4633d19
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/NQP/Actions.pm
Expand Up @@ -389,7 +389,7 @@ method routine_def($/) {
$past.blocktype('declaration');
$past.control('return_pir');
if $<deflongname> {
my $name := ~$<deflongname>[0].ast;
my $name := ~$<sigil>[0] ~ $<deflongname>[0].ast;
$past.name($name);
if $*SCOPE ne 'our' {
@BLOCK[0][0].push(PAST::Var.new( :name($name), :isdecl(1),
Expand Down
2 changes: 1 addition & 1 deletion src/NQP/Grammar.pm
Expand Up @@ -271,7 +271,7 @@ token routine_declarator:sym<sub> { <sym> <routine_def> }
token routine_declarator:sym<method> { <sym> <method_def> }

rule routine_def {
<deflongname>?
[ $<sigil>=['&'?]<deflongname> ]?
<.newpad>
[ '(' <signature> ')'
|| <.panic: 'Routine declaration requires a signature'> ]
Expand Down
10 changes: 9 additions & 1 deletion t/nqp/11-sub.t
Expand Up @@ -2,7 +2,7 @@

# check subs

say('1..11');
say('1..12');

sub one ( ) {
say("ok 1 # sub def and call");
Expand Down Expand Up @@ -74,3 +74,11 @@ sub eleven ($arg) {
say("ok 11 # parameter with a trailing comma");
}
eleven( 'dummy', );

sub &twelve() {
say("ok 12 # subroutine name with leading &");
}

&twelve();


0 comments on commit 4633d19

Please sign in to comment.