Fixes #2197 -- uncached double existential

This commit is contained in:
Jeremy Ashkenas 2012-04-25 15:04:15 -04:00
parent c1309e12f7
commit 879fe3976d
3 changed files with 10 additions and 3 deletions

View File

@ -2193,7 +2193,7 @@
Op.prototype.compileExistence = function(o) {
var fst, ref;
if (this.first.isComplex() && o.level > LEVEL_TOP) {
if (this.first.isComplex()) {
ref = new Literal(o.scope.freeVariable('ref'));
fst = new Parens(new Assign(ref, this.first));
} else {

View File

@ -1510,7 +1510,7 @@ exports.Op = class Op extends Base
"(#{code})"
compileExistence: (o) ->
if @first.isComplex() and o.level > LEVEL_TOP
if @first.isComplex()
ref = new Literal o.scope.freeVariable 'ref'
fst = new Parens new Assign ref, @first
else

View File

@ -274,4 +274,11 @@ test "#2155 ... conditional assignment to a closure", ->
x = null
func = -> x ?= (-> if true then 'hi')
func()
eq x(), 'hi'
eq x(), 'hi'
test "#2197: Existential existential double trouble", ->
counter = 0
func = -> counter++
func()? ? 100
eq counter, 1