Skip to content
Browse files

Fixes #2197 -- uncached double existential

  • Loading branch information...
1 parent c1309e1 commit 879fe3976d8de887511138610d6e5de652fcfe0e @jashkenas jashkenas committed Apr 25, 2012
Showing with 10 additions and 3 deletions.
  1. +1 −1 lib/coffee-script/nodes.js
  2. +1 −1 src/nodes.coffee
  3. +8 −1 test/operators.coffee
View
2 lib/coffee-script/nodes.js
@@ -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
2 src/nodes.coffee
@@ -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
9 test/operators.coffee
@@ -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
+

0 comments on commit 879fe39

Please sign in to comment.
Something went wrong with that request. Please try again.