Skip to content

CLI: Line numbers shown as NaN in stack trace when compiling CoffeeScript inside CoffeeScript #4558

@wastl-junior

Description

@wastl-junior

When calling the following script lineNumbers.coffee:

cs = require 'coffee-script'
cs.compile ""

throw new Error "Some Error"

using coffee lineNumbers.coffee
I get the following stacktrace:

Error: Some Error
    at Object.<anonymous> (F:\test\lineNumbers.coffee:NaN:NaN)
    at Object.<anonymous> (F:\test\lineNumbers.coffee:NaN:NaN)
    at Module._compile (module.js:NaN:NaN)
    at Object.exports.run (F:\test\node_modules\coffee-script\lib\coffee-script\coffee-script.js:NaN:NaN)
    at compileScript (F:\test\node_modules\coffee-script\lib\coffee-script\command.js:NaN:NaN)
    at compilePath (F:\test\node_modules\coffee-script\lib\coffee-script\command.js:NaN:NaN)
    at Object.exports.run (F:\test\node_modules\coffee-script\lib\coffee-script\command.js:NaN:NaN)
    at Object.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\coffee-script\bin\coffee:NaN:NaN)
    at Module._compile (module.js:NaN:NaN)
    at Object.Module._extensions..js (module.js:NaN:NaN)
    at Module.load (module.js:NaN:NaN)
    at tryModuleLoad (module.js:NaN:NaN)
    at Function.Module._load (module.js:NaN:NaN)
    at Module.runMain (module.js:NaN:NaN)
    at run (bootstrap_node.js:NaN:NaN)
    at startup (bootstrap_node.js:NaN:NaN)
    at bootstrap_node.js:NaN:NaN

When commenting the compile call out:

cs = require 'coffee-script_1_12_1_works'
#cs.compile ""

throw new Error "Some Error"

I get a reasonable line numbers:

Error: Some Error
    at Object.<anonymous> (F:\test\lineNumbers.coffee:4:7)
    at Object.<anonymous> (F:\test\lineNumbers.coffee:1:1)
    at Module._compile (module.js:571:32)
    at Object.exports.run (F:\test\node_modules\coffee-script\lib\coffee-script\coffee-script.js:173:23)
    at compileScript (F:\test\node_modules\coffee-script\lib\coffee-script\command.js:224:29)
    at compilePath (F:\test\node_modules\coffee-script\lib\coffee-script\command.js:174:14)
    at Object.exports.run (F:\test\node_modules\coffee-script\lib\coffee-script\command.js:98:20)
    at Object.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\coffee-script\bin\coffee:15:45)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:427:7)
    at startup (bootstrap_node.js:151:9)
    at bootstrap_node.js:542:3

This occurs using coffee-script 1.12.6. This behaviour is new, everything works correctly using coffee-script 1.12.1 and below. I also get proper line numbers using the newest coffeescript version when I execute the file using node -r coffee-script/register lineNumbers.coffee

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions