diff --git a/lib/nodes.js b/lib/nodes.js index 2ce6fdab..6b1fdc64 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -1702,7 +1702,7 @@ if (this.isExistentialEquals) { return new If(new Existence(fst).invert(), this.second, { type: 'if' - }).compile(o); + }).addElse(fst).compile(o); } else { return new If(new Existence(fst), ref, { type: 'if' diff --git a/src/nodes.coffee b/src/nodes.coffee index 7e6e2dbe..ee7dc965 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -1317,7 +1317,7 @@ exports.Op = class Op extends Base fst = @first ref = fst if @isExistentialEquals - new If(new Existence(fst).invert(), @second, type: 'if').compile o + new If(new Existence(fst).invert(), @second, type: 'if').addElse(fst).compile o else new If(new Existence(fst), ref, type: 'if').addElse(@second).compile o diff --git a/test/assignment.coffee b/test/assignment.coffee index f9fbb5e0..c3305e42 100644 --- a/test/assignment.coffee +++ b/test/assignment.coffee @@ -268,3 +268,9 @@ test "existential assignment", -> eq nonce, c d ?= nonce eq nonce, d + +test "#1348, #1216: existential assignment comilation", -> + nonce = {} + a = nonce + b = (a ?= 0) + eq nonce, b