added test for lexical scope sharing through generated closure wrappers, something uncommonly used, but that was a regression

This commit is contained in:
Jeremy Ashkenas
2010-01-24 13:39:27 -05:00
parent 817e8deb27
commit af53a04932
3 changed files with 13 additions and 4 deletions

View File

@@ -55,10 +55,11 @@ module CoffeeScript
closure ? compile_closure(@options) : compile_node(@options)
end
# Statements converted into expressions share scope with their parent
# closure, to preserve JavaScript-style lexical scope.
def compile_closure(o={})
indent = o[:indent]
@indent = (o[:indent] = idt(1))
ClosureNode.wrap(self).compile(o)
@indent = o[:indent]
ClosureNode.wrap(self).compile(o.merge(:shared_scope => o[:scope]))
end
# Quick short method for the current indentation level, plus tabbing in.