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:
parent
1e62781759
commit
fc0c4fdd5f
2 changed files with 4 additions and 0 deletions
|
@ -34,6 +34,9 @@
|
||||||
return fn.call(this, code, options);
|
return fn.call(this, code, options);
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
err = _error;
|
err = _error;
|
||||||
|
if (typeof code !== 'string') {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
throw helpers.updateSyntaxError(err, code, options.filename);
|
throw helpers.updateSyntaxError(err, code, options.filename);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,6 +26,7 @@ withPrettyErrors = (fn) ->
|
||||||
try
|
try
|
||||||
fn.call @, code, options
|
fn.call @, code, options
|
||||||
catch err
|
catch err
|
||||||
|
throw err if typeof code isnt 'string' # Support `CoffeeScript.nodes(tokens)`.
|
||||||
throw helpers.updateSyntaxError err, code, options.filename
|
throw helpers.updateSyntaxError err, code, options.filename
|
||||||
|
|
||||||
# Compile CoffeeScript code to JavaScript, using the Coffee/Jison compiler.
|
# Compile CoffeeScript code to JavaScript, using the Coffee/Jison compiler.
|
||||||
|
|
Loading…
Reference in a new issue