mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-01-14 17:27:59 -05:00
rewriter: detectEnd no longer passes undefined as token, fixing #750
This commit is contained in:
@@ -29,10 +29,10 @@
|
||||
return true;
|
||||
};
|
||||
exports.Rewriter.prototype.detectEnd = function(i, condition, action) {
|
||||
var levels, token;
|
||||
var levels, token, tokens;
|
||||
tokens = this.tokens;
|
||||
levels = 0;
|
||||
while (true) {
|
||||
token = this.tokens[i];
|
||||
while (token = tokens[i]) {
|
||||
if (levels === 0 && condition.call(this, token, i)) {
|
||||
return action.call(this, token, i);
|
||||
}
|
||||
|
||||
@@ -46,9 +46,9 @@ class exports.Rewriter
|
||||
true
|
||||
|
||||
detectEnd: (i, condition, action) ->
|
||||
{tokens} = this
|
||||
levels = 0
|
||||
loop
|
||||
token = @tokens[i]
|
||||
while token = tokens[i]
|
||||
return action.call this, token, i if levels is 0 and condition.call this, token, i
|
||||
return action.call this, token, i - 1 if not token or levels < 0
|
||||
if include EXPRESSION_START, token[0]
|
||||
|
||||
@@ -13,3 +13,10 @@ CoffeeScript.run("resultArray.push i for i of global", {noWrap: on, globals: on,
|
||||
ok 'setInterval' in global.resultArray
|
||||
|
||||
ok 'passed' is CoffeeScript.eval '"passed"', noWrap: on, globals: on, fileName: 'tests'
|
||||
|
||||
#750
|
||||
try
|
||||
CoffeeScript.nodes 'f(->'
|
||||
ok no
|
||||
catch e
|
||||
eq e.message, 'unclosed CALL_START on line 1'
|
||||
|
||||
Reference in New Issue
Block a user