mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
fixed a bug where postfix ?
was incorrectly unwrapping its operand
This commit is contained in:
parent
188ad03c17
commit
3ae818860b
3 changed files with 5 additions and 2 deletions
|
@ -1594,7 +1594,7 @@
|
|||
Existence.prototype.invert = NEGATE;
|
||||
Existence.prototype.compileNode = function(o) {
|
||||
var code, sym;
|
||||
code = this.expression.compile(o);
|
||||
code = this.expression.compile(o, LEVEL_OP);
|
||||
code = IDENTIFIER.test(code) && !o.scope.check(code) ? this.negated ? "typeof " + code + " == \"undefined\" || " + code + " === null" : "typeof " + code + " != \"undefined\" && " + code + " !== null" : (sym = this.negated ? '==' : '!=', "" + code + " " + sym + " null");
|
||||
if (o.level <= LEVEL_COND) {
|
||||
return code;
|
||||
|
|
|
@ -1216,7 +1216,7 @@ exports.Existence = class Existence extends Base
|
|||
constructor: (@expression) ->
|
||||
|
||||
compileNode: (o) ->
|
||||
code = @expression.compile o
|
||||
code = @expression.compile o, LEVEL_OP
|
||||
code = if IDENTIFIER.test(code) and not o.scope.check code
|
||||
if @negated
|
||||
"typeof #{code} == \"undefined\" || #{code} === null"
|
||||
|
|
|
@ -160,3 +160,6 @@ eq 1, a?.b.c + 1
|
|||
eq 1, a?.b.c += 1
|
||||
eq 2, ++a?.b.c
|
||||
eq yes, delete a?.b.c
|
||||
|
||||
|
||||
eq (1 or 0)?, true, 'postfix `?` should unwrap correctly'
|
||||
|
|
Loading…
Reference in a new issue