From af13f8dd2c18cf6c7c862f225bde24fc52c0317f Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Fri, 31 Jul 2020 15:50:16 +0100 Subject: [PATCH] improve diagnostics upon AST validation failure (#4033) --- lib/ast.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/ast.js b/lib/ast.js index 093e192c..2c27cbbe 100644 --- a/lib/ast.js +++ b/lib/ast.js @@ -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; })); }, -- 2.34.1