removing no_paren -- can cause order of operations errors

This commit is contained in:
Jeremy Ashkenas
2009-12-26 11:10:59 -08:00
parent 191875a85b
commit fde9852090
2 changed files with 6 additions and 3 deletions

View File

@@ -207,7 +207,7 @@ module CoffeeScript
def compile(o={}) def compile(o={})
o = super(o) o = super(o)
args = @arguments.map{|a| a.compile(o.merge(:no_paren => true)) }.join(', ') args = @arguments.map{|a| a.compile(o) }.join(', ')
return write(compile_super(args, o)) if super? return write(compile_super(args, o)) if super?
prefix = @new ? "new " : '' prefix = @new ? "new " : ''
write("#{prefix}#{@variable.compile(o)}(#{args})") write("#{prefix}#{@variable.compile(o)}(#{args})")
@@ -511,7 +511,7 @@ module CoffeeScript
o = super(o) o = super(o)
o.delete(:return) o.delete(:return)
indent = o[:indent] + TAB indent = o[:indent] + TAB
cond = @condition.compile(o.merge(:no_paren => true)) cond = @condition.compile(o)
write("while (#{cond}) {\n#{@body.compile(o.merge(:indent => indent))}\n#{o[:indent]}}") write("while (#{cond}) {\n#{@body.compile(o.merge(:indent => indent))}\n#{o[:indent]}}")
end end
end end
@@ -656,7 +656,7 @@ module CoffeeScript
o = super(o) o = super(o)
compiled = @expressions.compile(o) compiled = @expressions.compile(o)
compiled = compiled[0...-1] if compiled[-1..-1] == ';' compiled = compiled[0...-1] if compiled[-1..-1] == ';'
write(o[:no_paren] ? compiled : "(#{compiled})") write("(#{compiled})")
end end
end end

View File

@@ -4,3 +4,6 @@ f1: x =>
f2: y => f2: y =>
y * x y * x
elements.each(el =>
el.click(event =>
el.show() if event.active))