diff --git a/src/node.js b/src/node.js index 736559eaed011b..a9a85809096a6e 100644 --- a/src/node.js +++ b/src/node.js @@ -950,7 +950,10 @@ var source = NativeModule.getSource(this.id); source = NativeModule.wrap(source); - var fn = runInThisContext(source, { filename: this.filename }); + var fn = runInThisContext(source, { + filename: this.filename, + lineOffset: -1 + }); fn(this.exports, NativeModule.require, this, this.filename); this.loaded = true; diff --git a/test/message/core_line_numbers.js b/test/message/core_line_numbers.js new file mode 100644 index 00000000000000..ab86eb1e38f7f4 --- /dev/null +++ b/test/message/core_line_numbers.js @@ -0,0 +1,11 @@ +'use strict'; +const common = require('../common'); +const punycode = require('punycode'); + +// This test verifies that line numbers in core modules are reported correctly. +// The punycode module was chosen for testing because it changes infrequently. +// If this test begins failing, it is likely due to a punycode update, and the +// test's assertions simply need to be updated to reflect the changes. If a +// punycode update was not made, and this test begins failing, then line numbers +// are probably actually broken. +punycode.decode('x'); diff --git a/test/message/core_line_numbers.out b/test/message/core_line_numbers.out new file mode 100644 index 00000000000000..c4909774a0e6ec --- /dev/null +++ b/test/message/core_line_numbers.out @@ -0,0 +1,15 @@ +punycode.js:67 + throw new RangeError(errors[type]); + ^ + +RangeError: Invalid input + at error (punycode.js:67:*) + at Object.decode (punycode.js:*:*) + at Object. (*test*message*core_line_numbers.js:*:*) + at Module._compile (module.js:*:*) + at Object.Module._extensions..js (module.js:*:*) + at Module.load (module.js:*:*) + at Function.Module._load (module.js:*:*) + at Function.Module.runMain (module.js:*:*) + at startup (node.js:*:*) + at node.js:*:*