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

Commit

Permalink
Implement :flat :named (|%hash)
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed May 13, 2010
1 parent 9d4c8a9 commit 458dbfe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/NQP/Actions.pm
Expand Up @@ -614,6 +614,10 @@ method arglist($/) {
if $past[$i].name eq '&prefix:<|>' {
$past[$i] := $past[$i][0];
$past[$i].flat(1);
if $past[$i].isa(PAST::Val)
&& pir::substr($past[$i].name, 0, 1) eq '%' {
$past[$i].named(1);
}
}
$i++;
}
Expand Down
13 changes: 12 additions & 1 deletion t/nqp/41-flat.t
Expand Up @@ -2,14 +2,25 @@

# flattened arguments

plan(3);
plan(6);

sub xyz($x, $y, $z) {
ok( $x == 7, 'first argument');
ok( $y == 8, 'second argument');
ok( $z == 9, 'third argument');
}

sub ijk(:$i, :$j, :$k) {
ok( $i == 1, 'first named argument');
ok( $j == 2, 'second named argument');
ok( $k == 3, 'third named argument');
}

my @a := [7,8,9];
xyz(|@a);

my %a;
%a<i> := 1;
%a<j> := 2;
%a<k> := 3;
ijk(|%a);

0 comments on commit 458dbfe

Please sign in to comment.