diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-07-31 15:50:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-31 22:50:16 +0800 |
commit | af13f8dd2c18cf6c7c862f225bde24fc52c0317f (patch) | |
tree | fd0ea0799217ef944aed1ce39939f4990910106e | |
parent | 88423f2574bfd4f158caab1c08a5a5bf1718cab4 (diff) | |
download | tracifyjs-af13f8dd2c18cf6c7c862f225bde24fc52c0317f.tar.gz tracifyjs-af13f8dd2c18cf6c7c862f225bde24fc52c0317f.zip |
improve diagnostics upon AST validation failure (#4033)
-rw-r--r-- | lib/ast.js | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -123,7 +123,14 @@ var AST_Node = DEFNODE("Node", "start end", { validate_ast: function() { var marker = {}; this.walk(new TreeWalker(function(node) { - if (node.validate_visited === marker) throw new Error("invalid node reuse: " + node); + if (node.validate_visited === marker) { + throw new Error(string_template("cannot reuse {type} from [{file}:{line},{col}]", { + type: "AST_" + node.TYPE, + file: node.start.file, + line: node.start.line, + col: node.start.col, + })); + } node.validate_visited = marker; })); }, |