diff --git a/lib/nodes.js b/lib/nodes.js index 057b28d0..3ed557d9 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -481,10 +481,11 @@ })()); }; CallNode.prototype.compileNode = function(o) { - var _b, _c, _d, _e, _f, _g, _h, _i, arg, args, compilation; + var _b, _c, _d, _e, _f, _g, _h, _i, arg, args, code, op; if (!(o.chainRoot)) { o.chainRoot = this; } + op = this.tags.operation; if (this.exist) { _b = this.variable.compileReference(o, { precompile: true @@ -500,10 +501,10 @@ for (_c = 0, _e = _d.length; _c < _e; _c++) { arg = _d[_c]; if (arg instanceof SplatNode) { - compilation = this.compileSplat(o); + code = this.compileSplat(o); } } - if (!compilation) { + if (!code) { args = (function() { _f = []; _h = this.args; for (_g = 0, _i = _h.length; _g < _i; _g++) { @@ -515,9 +516,9 @@ } return _f; }).call(this); - compilation = this.isSuper ? this.compileSuper(args.join(', '), o) : ("" + (this.first) + (this.prefix()) + (this.meth) + "(" + (args.join(', ')) + ")" + (this.last)); + code = this.isSuper ? this.compileSuper(args.join(', '), o) : ("" + (this.first) + (this.prefix()) + (this.meth) + "(" + (args.join(', ')) + ")" + (this.last)); } - return compilation; + return op && this.variable && this.variable.wrapped ? ("(" + (code) + ")") : code; }; CallNode.prototype.compileSuper = function(args, o) { return "" + (this.superReference(o)) + ".call(this" + (args.length ? ', ' : '') + (args) + ")"; diff --git a/src/nodes.coffee b/src/nodes.coffee index 0dda0066..75c34786 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -440,22 +440,23 @@ exports.CallNode = class CallNode extends BaseNode # Compile a vanilla function call. compileNode: (o) -> o.chainRoot = this unless o.chainRoot + op = @tags.operation if @exist [@first, @meth] = @variable.compileReference o, precompile: yes @first = "(typeof #{@first} === \"function\" ? " @last = " : undefined)" else if @variable then @meth = @variable.compile o for arg in @args when arg instanceof SplatNode - compilation = @compileSplat(o) - if not compilation + code = @compileSplat(o) + if not code args = for arg in @args arg.parenthetical = true arg.compile o - compilation = if @isSuper + code = if @isSuper @compileSuper(args.join(', '), o) else "#{@first}#{@prefix()}#{@meth}(#{ args.join(', ') })#{@last}" - compilation + if op and @variable and @variable.wrapped then "(#{code})" else code # `super()` is converted into a call against the superclass's implementation # of the current function. diff --git a/test/test_existence.coffee b/test/test_existence.coffee index c34bc5ed..6d0ee766 100644 --- a/test/test_existence.coffee +++ b/test/test_existence.coffee @@ -75,6 +75,8 @@ result = value?.toString().toLowerCase() ok result is '10' +ok(process.exit.nothing?.property() or 101) + # Soaks inner values. ident = (obj) -> obj