diff --git a/lib/nodes.js b/lib/nodes.js index 2cd5d164..5d18b7b9 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -353,7 +353,7 @@ return this.base instanceof LiteralNode && this.base.value.match(NUMBER); }; ValueNode.prototype.cacheIndexes = function(o) { - var _len, _ref2, _ref3, copy, i, index, indexVar, prop; + var _len, _ref2, _ref3, copy, first, i, index, indexVar, prop; copy = new ValueNode(this.base, this.properties.slice(0)); if (this.base.isComplex()) { _ref2 = this.base.compileReference(o); @@ -367,8 +367,11 @@ _ref3 = prop.index.compileReference(o); index = _ref3[0]; indexVar = _ref3[1]; - this.properties[i] = new IndexNode(index); + this.properties[i] = (first = new IndexNode(index)); copy.properties[i] = new IndexNode(indexVar); + if (prop.soakNode) { + first.soakNode = true; + } } } return [this, copy]; diff --git a/src/nodes.coffee b/src/nodes.coffee index 85485eba..863fc41d 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -346,9 +346,10 @@ exports.ValueNode = class ValueNode extends BaseNode [@base, copy.base] = @base.compileReference o for prop, i in copy.properties if prop instanceof IndexNode and prop.index.isComplex() - [index, indexVar] = prop.index.compileReference o - this.properties[i] = new IndexNode index + [index, indexVar] = prop.index.compileReference o + this.properties[i] = first = new IndexNode index copy.properties[i] = new IndexNode indexVar + first.soakNode = yes if prop.soakNode [this, copy] # Override compile to unwrap the value when possible. diff --git a/test/test_existence.coffee b/test/test_existence.coffee index b483b1aa..21ad73a3 100644 --- a/test/test_existence.coffee +++ b/test/test_existence.coffee @@ -147,3 +147,5 @@ ok (maybe_close plus1, 41)?() is 42 ok (maybe_close 'string', 41)?() is undefined ok 2?(3) is undefined + +ok calendar?[Date()] is undefined