The set of "free variables" available to closures is intentionally restricted (based on what references can be discovered at load time) so that the function can be allowed to clear its other local variables when it returns. Aside from generally being conservative, this avoids creating circular references in some cases, such as:
- when the function stores a reference to a closure in a local variable,
- when the function stores a reference to a closure in an object referred by a local variable, such as this in a method,
... but doesn't refer to that variable within any closures.
A circular reference would prevent the closure, all associated free variables, all objects referred by those variables and so on, from being freed until the circle is broken. Breaking a circular reference is harder for closures than for objects because the variables are not accessible from outside.