mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 19:34:27 -05:00
removing the constructor safety check -- it wasn't safe enough (Issue 36)
This commit is contained in:
@@ -171,11 +171,8 @@ module CoffeeScript
|
||||
return "#{stmt ? '' : idt}#{node.compile(o.merge(:top => true))}#{stmt ? '' : ';'}" unless returns
|
||||
# If it's a statement, the node knows how to return itself.
|
||||
return node.compile(o.merge(:return => true)) if node.statement?
|
||||
# If it's not part of a constructor, we can just return the value of the expression.
|
||||
return "#{idt}return #{node.compile(o)};" unless o[:scope].function && o[:scope].function.constructor?
|
||||
# It's the last line of a constructor, add a safety check.
|
||||
temp = o[:scope].free_variable
|
||||
"#{idt}#{temp} = #{node.compile(o)};\n#{idt}return #{o[:scope].function.name} === this.constructor ? this : #{temp};"
|
||||
# Otherwise, we can just return the value of the expression.
|
||||
return "#{idt}return #{node.compile(o)};"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user