1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

reserving variables for splats the regular way, not through a custom 'var' declaration

This commit is contained in:
Jeremy Ashkenas 2009-12-31 18:03:39 -05:00
parent 1d2bb3b2be
commit 26c89cef06

View file

@ -463,12 +463,12 @@ module CoffeeScript
o.delete(:assign)
o.delete(:no_wrap)
name = o.delete(:immediate_assign)
@params.each {|id| o[:scope].parameter(id.to_s) }
if @params.last.is_a?(SplatNode)
splat = @params.pop
splat.index = @params.length
@body.unshift(splat)
end
@params.each {|id| o[:scope].parameter(id.to_s) }
code = @body.compile(o, :code)
name_part = name ? " #{name}" : ''
write("function#{name_part}(#{@params.join(', ')}) {\n#{code}\n#{indent}}")
@ -484,12 +484,9 @@ module CoffeeScript
@name = name
end
def to_s
@name
end
def compile(o={})
"var #{@name} = Array.prototype.slice.call(arguments, #{@index})"
o[:scope].find(@name)
"#{@name} = Array.prototype.slice.call(arguments, #{@index})"
end
end