1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Fix CoffeeScript.nodes(tokens); fix the repl

If you passed an array of tokens (as opposed to a string of code) to
`CoffeeScript.nodes`, its attempts to prettify error messages would break. Now
it does not attempt to prettify error messages in that case anymore (because it
is not possible to prettify the errors without a string of code).

The repl was affected by the above bug.

Fixes #3887.
This commit is contained in:
Simon Lydell 2015-05-01 13:43:04 +02:00
parent 1e62781759
commit fc0c4fdd5f
2 changed files with 4 additions and 0 deletions

View file

@ -34,6 +34,9 @@
return fn.call(this, code, options);
} catch (_error) {
err = _error;
if (typeof code !== 'string') {
throw err;
}
throw helpers.updateSyntaxError(err, code, options.filename);
}
};

View file

@ -26,6 +26,7 @@ withPrettyErrors = (fn) ->
try
fn.call @, code, options
catch err
throw err if typeof code isnt 'string' # Support `CoffeeScript.nodes(tokens)`.
throw helpers.updateSyntaxError err, code, options.filename
# Compile CoffeeScript code to JavaScript, using the Coffee/Jison compiler.