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