Skip to content

Commit

Permalink
assert: fix line number calculation after V8 upgrade
Browse files Browse the repository at this point in the history
Backport-PR-URL: #30109
PR-URL: #29694
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
  • Loading branch information
targos authored and BethGriggs committed Feb 6, 2020
1 parent 0df4910 commit b4e8f0d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/assert.js
Expand Up @@ -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;
Expand All @@ -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}`;
}

Expand Down

0 comments on commit b4e8f0d

Please sign in to comment.