added the constructor fix for capitalized functions

This commit is contained in:
Jeremy Ashkenas
2010-01-06 23:34:56 -05:00
parent cf7079a379
commit 9ed8020b84
2 changed files with 6 additions and 3 deletions

View File

@@ -100,7 +100,9 @@ module CoffeeScript
if node.statement?
node.compile(o.merge(:return => true))
else
"#{o[:indent]}return #{node.compile(o)};"
constructor = o[:top] && o[:last_assign] && o[:last_assign][0..0][/[A-Z]/]
prefix = constructor ? "if (#{o[:last_assign]} !== this.constructor) " : ''
"#{o[:indent]}#{prefix}return #{node.compile(o)};"
end
else
ending = node.statement? ? '' : ';'