rewriter: detectEnd no longer passes undefined as token, fixing #750

This commit is contained in:
satyr
2010-10-09 04:00:07 +09:00
parent b21057d166
commit ebdd57a2fe
3 changed files with 12 additions and 5 deletions

View File

@@ -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);
}

View File

@@ -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]

View File

@@ -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'