var found = false;
return statements[stat_index].transform(new TreeTransformer(function(node, descend, in_list) {
if (found) return node;
- if (node === expr || node.body === expr) {
+ if (node !== expr && node.body !== expr) return;
+ if (node instanceof AST_VarDef) {
found = true;
- if (node instanceof AST_VarDef) {
- node.value = null;
- return node;
- }
- return in_list ? MAP.skip : null;
+ node.value = null;
+ return node;
+ }
+ if (in_list) {
+ found = true;
+ return MAP.skip;
+ }
+ if (!this.parent()) {
+ found = true;
+ return null;
}
}, function(node) {
if (node instanceof AST_Sequence) switch (node.expressions.length) {