assert: fix line number calculation after V8 upgrade

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Michaël Zasso 2019-08-28 10:05:32 +02:00 committed by Myles Borins
parent 1676502318
commit 5981fb7faa
No known key found for this signature in database
GPG Key ID: 933B01F40B5CA946

View File

@ -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;
@ -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}`;
}