mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Fixing issue #678 -- missing parentheses in a mixed operation(call(soak))
This commit is contained in:
parent
121110a485
commit
4af41e9bfb
3 changed files with 13 additions and 9 deletions
11
lib/nodes.js
11
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) + ")";
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue