Commit 212383bf authored by Kevin Modzelewski's avatar Kevin Modzelewski

Make the del statement work inside functions

parent 2c2cf09e
......@@ -210,6 +210,13 @@ public:
virtual bool visit_jump(AST_Jump* node) { return false; }
virtual bool visit_delete(AST_Delete* node) {
for (auto t : node->targets) {
RELEASE_ASSERT(t->type != AST_TYPE::Name, "");
}
return false;
}
virtual bool visit_global(AST_Global* node) {
for (int i = 0; i < node->names.size(); i++) {
const std::string& name = node->names[i];
......
......@@ -15,3 +15,12 @@ del a[:]
print a
a.append(1)
print a
# Make sure that del's work correctly in sub-scopes:
x = 1
def f1():
x = range(5)
def f2():
del x[1]
return f2
f1()()
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