Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow $*FOO as parameters
  • Loading branch information
sorear committed Oct 15, 2010
1 parent 9615df7 commit 1e0987f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/Niecza/Actions.pm
Expand Up @@ -1620,12 +1620,23 @@ sub param_var { my ($cl, $M) = @_;
}
my $twigil = $M->{twigil}[0] ? $M->{twigil}[0]->Str : '';
my $sigil = $M->{sigil}->Str;
if ($twigil || ($sigil ne '$' && $sigil ne '@' && $sigil ne '%' && $sigil ne '&')) {

my $slot;
if ($twigil eq '') {
$slot = $M->{name}[0] ? ($sigil . $M->{name}[0]->Str) : undef;
} elsif ($twigil eq '*') {
$slot = "$sigil*" . $M->{name}[0]->Str;
} else {
$M->sorry("Unhandled parameter twigil $twigil");
return;
}

if ($sigil ne '$' && $sigil ne '@' && $sigil ne '%' && $sigil ne '&') {
$M->sorry('Non bare scalar targets NYI');
return;
}
$M->{_ast} = { list => ($sigil eq '@'), hash => ($sigil eq '%'), slot =>
$M->{name}[0] ? ($sigil . $M->{name}[0]->Str) : undef };
$M->{_ast} = { list => ($sigil eq '@'), hash => ($sigil eq '%'),
slot => $slot };
}

# :: Sig::Parameter
Expand Down
6 changes: 6 additions & 0 deletions test2.pl
Expand Up @@ -52,6 +52,12 @@ sub infix:<lt>($s1, $s2) { ($s1 leg $s2) < 0 }
is ("yayay" ~~ /y\w*?y/), "yay", "minimal matching works";
is ("yayay" ~~ /y**?a/), "y", "minimal matching works with **";
{
sub bar { $*x + $*x }
sub foo($*x) { bar }
is foo(12), 24, "*-twigilled arguments work";
}
#is $?FILE, 'test.pl', '$?FILE works';
#is $?ORIG.substr(0,5), '# vim', '$?ORIG works';
Expand Down

0 comments on commit 1e0987f

Please sign in to comment.