Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

1.6.2, node 0.8.14: `prettyErrorMessage` fails in require()d script #2849

Closed
saschagehlich opened this Issue Mar 18, 2013 · 2 comments

Comments

Projects
None yet
3 participants

a.coffee

require './b'

b.coffee

test 'parameter'
  key: 'val'

Note that in b.coffee a , is missing after 'parameter'. Running coffee ./a.coffee results in:

/Users/saschagehlich/nvm/v0.8.14/lib/node_modules/coffee-script/lib/coffee-script/helpers.js:229
      codeLine = codeLine.slice(0, start) + colorize(codeLine.slice(start, end
                          ^
TypeError: Cannot call method 'slice' of undefined
  at Object.exports.prettyErrorMessage (/Users/saschagehlich/nvm/v0.8.14/lib/node_modules/coffee-script/lib/coffee-script/helpers.js:229:27)
  at compileScript (/Users/saschagehlich/nvm/v0.8.14/lib/node_modules/coffee-script/lib/coffee-script/command.js:203:25)
  at fs.stat.notSources.(anonymous function) (/Users/saschagehlich/nvm/v0.8.14/lib/node_modules/coffee-script/lib/coffee-script/command.js:144:18)
  at fs.readFile (fs.js:176:14)
  at Object.oncomplete (fs.js:297:15)

Same for node 0.10.0

Also, if I turn b.coffee into:

test 'parameter' key: 'val'

coffee ./a.coffee results in

./a.coffee:1:18: error: unexpected {
require './b'
                 ^

Which is not quire helpful...

Contributor

epidemian commented Mar 18, 2013

Thanks for the report. It seems nobody remembered to test these error messages with require()d files (certainly i didn't 😓 ). I'll try to give this a look when i get home.

It seems both errors are caused by the same underlying problem: the fileName and code arguments that reach helpers/prettyMessage do not correspond to the required()d file for some reason (in your second example it didn't explode simply because the a.coffee file has 1st line).

@epidemian epidemian added a commit to epidemian/coffee-script that referenced this issue Mar 19, 2013

@epidemian epidemian Fixes #2849: now the compilation errors thrown by CoffeeScript.compil…
…e will include the correct filename and source code information
67fd84f

@jashkenas jashkenas closed this in #2856 Jun 9, 2013

@jashkenas jashkenas added a commit that referenced this issue Jun 9, 2013

@jashkenas jashkenas Merge pull request #2856 from epidemian/issue2849
Fixes #2849: use correct filename and code in require()d sources
13187b0

eldamir commented Sep 16, 2013

I am experiencing exactly this issue in 1.6.3 :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment