mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
added test for lexical scope sharing through generated closure wrappers, something uncommonly used, but that was a regression
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -51,4 +51,5 @@ arr: ["--", "----"]
|
||||
print(arr.pop()?.length is 4)
|
||||
print(arr.pop()?.length is 2)
|
||||
print(arr.pop()?.length is undefined)
|
||||
print(arr[0]?.length is undefined)
|
||||
print(arr.pop()?.length?.non?.existent()?.property is undefined)
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
num: 1 + 2 + (a: 3)
|
||||
|
||||
print(num is 6)
|
||||
print(num is 6)
|
||||
|
||||
|
||||
result: if true
|
||||
false
|
||||
other: "result"
|
||||
|
||||
print(result is "result" and other is "result")
|
||||
Reference in New Issue
Block a user