From 6c9ef76b95e15b907d4acc1bbaa749a76a4b6d3b Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Wed, 11 May 2011 00:08:24 -0400 Subject: [PATCH] fixed behavioural change accidentally introduced by #1348, thanks @satyr --- lib/nodes.js | 2 +- src/nodes.coffee | 2 +- test/assignment.coffee | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) 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