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

Commit

Permalink
Don't put named (slurpy) parameters into multi-signature. Closes TT #…
Browse files Browse the repository at this point in the history
…1736
  • Loading branch information
bacek committed Aug 26, 2010
1 parent e71d569 commit 83747bd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/NQP/Actions.pm
Expand Up @@ -490,7 +490,7 @@ method signature($/) {
if $*MULTINESS eq "multi" {
my @params;
for $BLOCKINIT.list {
@params.push($_.multitype // '_');
@params.push($_.multitype // '_') unless $_<skip_multi>;
}
@BLOCK[0].multi(@params);
}
Expand All @@ -504,15 +504,18 @@ method parameter($/) {
if $quant ne '!' {
$past.viviself( vivitype($<named_param><param_var><sigil>) );
}
$past<skip_multi> := 1;
}
else {
$past := $<param_var>.ast;
if $quant eq '*' {
$past.slurpy(1);
$past.named( $<param_var><sigil> eq '%' );
$past<skip_multi> := 1;
}
elsif $quant eq '?' {
$past.viviself( vivitype($<param_var><sigil>) );
$past<skip_multi> := 1;
}
}
if $<default_value> {
Expand Down
17 changes: 16 additions & 1 deletion t/nqp/51-multi.t
@@ -1,6 +1,6 @@
#! nqp

say("1..5");
say("1..7");

our multi sub foo(Float $f) {
say("ok 1");
Expand Down Expand Up @@ -32,3 +32,18 @@ my $f := Foo.new;
$f.bar(43.5 - 0.5);
$f.bar("ok 5");


class Bar {
our multi method foo($x, :$opt?) {
say($x);
}

our multi method foo(Float $x, :$opt?) {
say("ok 6");
}
}

my $b := Bar.new;
$b.foo(43.5 - 0.5);
$b.foo("ok 7");

0 comments on commit 83747bd

Please sign in to comment.