Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix multimethods and implement lexical proto shadowing
  • Loading branch information
sorear committed May 12, 2011
1 parent 7c63a3c commit 2703ab0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions lib/CLRBackend.cs
Expand Up @@ -2599,6 +2599,8 @@ class NamProcessor {
}
}
if (csr.outer == null) break;
// don't go above nearest proto
if (csr.l_lexicals.ContainsKey(pn)) break;
if (brk) cands.Add(CpsOp.Null(Tokens.P6any));
}

Expand Down
6 changes: 4 additions & 2 deletions lib/Kernel.cs
Expand Up @@ -1414,6 +1414,7 @@ public class MMDCandidateLongname {
int[] links = new int[raw.Length * raw.Length * 2];
int ap = 0;
int[] heads = new int[raw.Length * 2];
int[] orig = new int[raw.Length];
MMDCandidateLongname[] lns = new MMDCandidateLongname[raw.Length];
int nlns = 0;
int tien = 0;
Expand All @@ -1423,6 +1424,7 @@ public class MMDCandidateLongname {
tien++;
} else {
lns[nlns] = new MMDCandidateLongname(raw[i], tien);
orig[nlns] = i;
heads[2*nlns] = -1;
nlns++;
}
Expand Down Expand Up @@ -1460,7 +1462,7 @@ public class MMDCandidateLongname {
}
// prevent constrained candidates from being part of a tie
if (lns[i].extra_constraints) outp.Add(null);
outp.Add(raw[i]);
outp.Add(raw[orig[i]]);
if (lns[i].extra_constraints) outp.Add(null);
k--;
}
Expand Down Expand Up @@ -1495,7 +1497,7 @@ public class MMDCandidateLongname {
//Console.WriteLine(".");
continue;
}
//Console.WriteLine((new MMDCandidateLongname(p)).LongName());
//Console.WriteLine((new MMDCandidateLongname(p,0)).LongName());
SubInfo si = (SubInfo)p.GetSlot("info");
Frame o = (Frame)p.GetSlot("outer");
Frame nth = th.MakeChild(o, si);
Expand Down
12 changes: 6 additions & 6 deletions test.pl
Expand Up @@ -2,7 +2,7 @@

use Test;

plan 827;
plan 828;

ok 1, "one is true";
ok 2, "two is also true";
Expand Down Expand Up @@ -1913,11 +1913,11 @@
is foo(True), "bool", "augmenting multisubs works (1)";
is foo(5), "any", "augmenting multisubs works (2)";
# {
# proto foo($) {*}
# multi foo(Any $) { "any2" }
# is foo(True), "any2", "proto-shadowing works";
# }
{
proto foo($) {*}
multi foo(Any $) { "any2" }
is foo(True), "any2", "proto-shadowing works";
}
{
sub foo(Any $) { "any3" }
Expand Down

0 comments on commit 2703ab0

Please sign in to comment.