Skip to content

Commit

Permalink
assert: fix line number calculation after V8 upgrade
Browse files Browse the repository at this point in the history
PR-URL: nodejs#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 MylesBorins committed Oct 7, 2019
1 parent 1676502 commit 5981fb7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,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 @@ -289,6 +289,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 5981fb7

Please sign in to comment.