Commit 6fecfd16 authored by Travis Hance's avatar Travis Hance

address kmod's comments on static closures

parent 5082369a
......@@ -98,8 +98,8 @@ public:
virtual DerefInfo getDerefInfo(InternedString name) = 0;
// Gets the DerefInfo for each DEREF variable accessible in the scope.
// The returned vector is in SORTED ORDER by the `num_parents_from_passed_closure` field.
// This allows the caller to iterate through the vector while also walking up
// The returned vector is in SORTED ORDER by the `num_parents_from_passed_closure` field
// (ascending). This allows the caller to iterate through the vector while also walking up
// the closure chain to collect all the DEREF variable values. This is useful, for example,
// in the implementation of locals().
//
......
......@@ -1277,7 +1277,6 @@ Box* getattrInternalGeneric(Box* obj, const std::string& attr, GetattrRewriteArg
*bind_obj_out = NULL;
}
// TODO this should be a custom getattr
assert(obj->cls != closure_cls);
// Handle descriptor logic here.
......
# should_error
# The use of c makes sure a closure gets passed through all 4 functions.
# The use of a in g makes sure that a is in f's closure.
# The a in j should refer to the a in h, thus throwing an exception since
# it is undefined (that is, it should *not* access the a from f even
# though it access via the closure).
def f():
try:
def f():
c = 0
a = 0
def g():
......@@ -22,4 +21,6 @@ def f():
a = 1
h()
g()
f()
f()
except NameError as ne:
print ne.message
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment