Fixing issue #678 -- missing parentheses in a mixed operation(call(soak))

This commit is contained in:
Jeremy Ashkenas
2010-09-11 08:39:14 -04:00
parent 121110a485
commit 4af41e9bfb
3 changed files with 13 additions and 9 deletions

View File

@@ -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.