diff --git a/lib/assert.js b/lib/assert.js index a83dba770e0344..d307582d1fde7d 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -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}`; }