From b4e8f0de1285198d2a399c784cde20234425153b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Wed, 28 Aug 2019 10:05:32 +0200 Subject: [PATCH] assert: fix line number calculation after V8 upgrade MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backport-PR-URL: https://github.com/nodejs/node/pull/30109 PR-URL: https://github.com/nodejs/node/pull/29694 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: Gus Caplan Reviewed-By: Jiawen Geng Reviewed-By: Michaël Zasso Reviewed-By: Tobias Nießen Reviewed-By: Ujjwal Sharma --- lib/assert.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/assert.js b/lib/assert.js index 3396e643182f1b..d4068fc96831c1 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -268,7 +268,7 @@ function getErrMessage(message, fn) { const call = err.stack[0]; const filename = call.getFileName(); - const line = call.getLineNumber() - 1; + let line = call.getLineNumber() - 1; let column = call.getColumnNumber() - 1; let identifier; let code; @@ -288,6 +288,9 @@ function getErrMessage(message, fn) { return message; } code = String(fn); + // For functions created with the Function constructor, V8 does not count + // the lines containing the function header. + line += 2; identifier = `${code}${line}${column}`; }