Skip to content

Commit 5bd6947

Browse files
targosMylesBorins
authored andcommitted
assert: fix line number calculation after V8 upgrade
Backport-PR-URL: #30109 PR-URL: #29694 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]>
1 parent 6a17aec commit 5bd6947

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/assert.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ function getErrMessage(message, fn) {
268268
const call = err.stack[0];
269269

270270
const filename = call.getFileName();
271-
const line = call.getLineNumber() - 1;
271+
let line = call.getLineNumber() - 1;
272272
let column = call.getColumnNumber() - 1;
273273
let identifier;
274274
let code;
@@ -288,6 +288,9 @@ function getErrMessage(message, fn) {
288288
return message;
289289
}
290290
code = String(fn);
291+
// For functions created with the Function constructor, V8 does not count
292+
// the lines containing the function header.
293+
line += 2;
291294
identifier = `${code}${line}${column}`;
292295
}
293296

0 commit comments

Comments
 (0)