Skip to content

Commit b159235

Browse files
committed
[js] Stop caching captures with named arguments
The partial way we did was causing problems
1 parent 99abffd commit b159235

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/vm/js/nqp-runtime/multicache.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ var op = {};
5858
op.multicachefind = function(ctx, cache, capture) {
5959
if (!(cache instanceof MultiCache)) return Null;
6060
var arity = capture.pos.length;
61-
var hasNamed = capture.named ? true : false;
61+
if (capture.named) return Null;
6262

6363
if (arity == 0) {
64-
if (!hasNamed && cache.zeroArity) {
64+
if (cache.zeroArity) {
6565
return cache.zeroArity;
6666
} else {
6767
return Null;
@@ -78,7 +78,6 @@ op.multicachefind = function(ctx, cache, capture) {
7878
for (var j = 0; j < arityCache[i].types.length; j++) {
7979
if (arityCache[i].types[j] !== types[j]) continue CANDIDATES;
8080
}
81-
if (arityCache[i].hasNamed !== hasNamed) continue CANDIDATES;
8281
return arityCache[i].result;
8382
}
8483

@@ -87,21 +86,19 @@ op.multicachefind = function(ctx, cache, capture) {
8786

8887
op.multicacheadd = function(ctx, cache, capture, result) {
8988
var c = cache instanceof MultiCache ? cache : new MultiCache();
89+
if (c.named) return c;
9090
var arity = capture.pos.length;
91-
var hasNamed = capture.named ? true : false;
9291

9392
if (arity == 0) {
94-
if (!hasNamed) {
95-
c.zeroArity = result;
96-
}
93+
c.zeroArity = result;
9794
return c;
9895
}
9996

10097
if (arity > MAX_ARITY || c.cache[arity - 1].length > MAX_PER_ARITY) {
10198
return c;
10299
}
103100

104-
c.cache[arity - 1].push({types: posTypes(ctx, capture), hasNamed: hasNamed, result: result});
101+
c.cache[arity - 1].push({types: posTypes(ctx, capture), result: result});
105102
return c;
106103
};
107104

0 commit comments

Comments
 (0)