aboutsummaryrefslogtreecommitdiff
path: root/lib/ast.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-07-31 01:09:19 +0100
committerGitHub <noreply@github.com>2020-07-31 08:09:19 +0800
commit88423f2574bfd4f158caab1c08a5a5bf1718cab4 (patch)
tree57bf9646a755320b038d1cd0799758ff2c0741dd /lib/ast.js
parentee632a5519078ac3fe97d0864731bea4bdad9365 (diff)
downloadtracifyjs-88423f2574bfd4f158caab1c08a5a5bf1718cab4.tar.gz
tracifyjs-88423f2574bfd4f158caab1c08a5a5bf1718cab4.zip
validate against multiple parents on `AST_Node` (#4032)
- fix related issues in `global_defs`, `ie8` & `reduce_vars`
Diffstat (limited to 'lib/ast.js')
-rw-r--r--lib/ast.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/ast.js b/lib/ast.js
index 31072a08..093e192c 100644
--- a/lib/ast.js
+++ b/lib/ast.js
@@ -120,6 +120,13 @@ var AST_Node = DEFNODE("Node", "start end", {
ctor.prototype._validate.call(this);
} while (ctor = ctor.BASE);
},
+ validate_ast: function() {
+ var marker = {};
+ this.walk(new TreeWalker(function(node) {
+ if (node.validate_visited === marker) throw new Error("invalid node reuse: " + node);
+ node.validate_visited = marker;
+ }));
+ },
}, null);
(AST_Node.log_function = function(fn, verbose) {