Permalink
Browse files

Properly handle unscoped multi methods/subs

  • Loading branch information...
1 parent cb33a76 commit f11a416625a0748530018f7b11c9f07c58a9d7f0 @bacek bacek committed Jan 10, 2011
Showing with 15 additions and 3 deletions.
  1. +1 −0 src/NQP/Actions.pm
  2. +14 −3 t/nqp/51-multi.t
View
1 src/NQP/Actions.pm
@@ -307,6 +307,7 @@ method term:sym<variable>($/) { make $<variable>.ast; }
method term:sym<package_declarator>($/) { make $<package_declarator>.ast; }
method term:sym<scope_declarator>($/) { make $<scope_declarator>.ast; }
method term:sym<routine_declarator>($/) { make $<routine_declarator>.ast; }
+method term:sym<multi_declarator>($/) { make $<multi_declarator>.ast; }
method term:sym<regex_declarator>($/) { make $<regex_declarator>.ast; }
method term:sym<statement_prefix>($/) { make $<statement_prefix>.ast; }
method term:sym<lambda>($/) { make $<pblock>.ast; }
View
17 t/nqp/51-multi.t
@@ -1,6 +1,6 @@
#! nqp
-say("1..7");
+say("1..9");
our multi sub foo(Float $f) {
say("ok 1");
@@ -26,11 +26,22 @@ class Foo {
our multi method bar($f) {
say($f);
};
+
+ multi method baz(Integer $i) {
+ say("ok 6");
+ }
+
+ multi method baz($i) {
+ say($i);
+ };
+
};
my $f := Foo.new;
$f.bar(43.5 - 0.5);
$f.bar("ok 5");
+$f.baz(42);
+$f.baz("ok 7");
class Bar {
@@ -39,11 +50,11 @@ class Bar {
}
our multi method foo(Float $x, :$opt?) {
- say("ok 6");
+ say("ok 8");
}
}
my $b := Bar.new;
$b.foo(43.5 - 0.5);
-$b.foo("ok 7");
+$b.foo("ok 9");

0 comments on commit f11a416

Please sign in to comment.