From 7b38623b5fdc364cd4945f03e50ea8dc19fb4502 Mon Sep 17 00:00:00 2001 From: Norbiros Date: Sun, 26 Jan 2025 17:32:33 +0100 Subject: [PATCH] Include file name in `SyntaxError` message if present FIX: Mention the source file name in syntax error messages when given. --- acorn/src/location.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/acorn/src/location.js b/acorn/src/location.js index a7a2d6cf8..ef5265507 100644 --- a/acorn/src/location.js +++ b/acorn/src/location.js @@ -12,6 +12,9 @@ const pp = Parser.prototype pp.raise = function(pos, message) { let loc = getLineInfo(this.input, pos) message += " (" + loc.line + ":" + loc.column + ")" + if (this.sourceFile) { + message += " in " + this.sourceFile + } let err = new SyntaxError(message) err.pos = pos; err.loc = loc; err.raisedAt = this.pos throw err