Skip to content
This repository
Browse code

Properly handle unscoped multi methods/subs

  • Loading branch information...
commit f11a416625a0748530018f7b11c9f07c58a9d7f0 1 parent cb33a76
Vasily Chekalkin authored January 10, 2011
1  src/NQP/Actions.pm
@@ -307,6 +307,7 @@ method term:sym<variable>($/)           { make $<variable>.ast; }
307 307
 method term:sym<package_declarator>($/) { make $<package_declarator>.ast; }
308 308
 method term:sym<scope_declarator>($/)   { make $<scope_declarator>.ast; }
309 309
 method term:sym<routine_declarator>($/) { make $<routine_declarator>.ast; }
  310
+method term:sym<multi_declarator>($/)   { make $<multi_declarator>.ast; }
310 311
 method term:sym<regex_declarator>($/)   { make $<regex_declarator>.ast; }
311 312
 method term:sym<statement_prefix>($/)   { make $<statement_prefix>.ast; }
312 313
 method term:sym<lambda>($/)             { make $<pblock>.ast; }
17  t/nqp/51-multi.t
... ...
@@ -1,6 +1,6 @@
1 1
 #! nqp
2 2
 
3  
-say("1..7");
  3
+say("1..9");
4 4
 
5 5
 our multi sub foo(Float $f) {
6 6
     say("ok 1");
@@ -26,11 +26,22 @@ class Foo {
26 26
     our multi method bar($f) {
27 27
         say($f);
28 28
     };
  29
+
  30
+    multi method baz(Integer $i) {
  31
+        say("ok 6");
  32
+    }
  33
+
  34
+    multi method baz($i) {
  35
+        say($i);
  36
+    };
  37
+
29 38
 };
30 39
 
31 40
 my $f := Foo.new;
32 41
 $f.bar(43.5 - 0.5);
33 42
 $f.bar("ok 5");
  43
+$f.baz(42);
  44
+$f.baz("ok 7");
34 45
 
35 46
 
36 47
 class Bar {
@@ -39,11 +50,11 @@ class Bar {
39 50
     }
40 51
 
41 52
     our multi method foo(Float $x, :$opt?) {
42  
-        say("ok 6");
  53
+        say("ok 8");
43 54
     }
44 55
 }
45 56
 
46 57
 my $b := Bar.new;
47 58
 $b.foo(43.5 - 0.5);
48  
-$b.foo("ok 7");
  59
+$b.foo("ok 9");
49 60
 

0 notes on commit f11a416

Please sign in to comment.
Something went wrong with that request. Please try again.