fixing implicit invocations against inline try/catch.

This commit is contained in:
Jeremy Ashkenas 2011-05-15 15:04:29 -04:00
parent cd5c41f351
commit 9e32a5bfa1
3 changed files with 6 additions and 2 deletions

View File

@ -190,7 +190,7 @@
if (!seenSingle && token.fromThen) {
return true;
}
if (tag === 'IF' || tag === 'ELSE' || tag === '->' || tag === '=>') {
if (tag === 'IF' || tag === 'ELSE' || tag === 'CATCH' || tag === '->' || tag === '=>') {
seenSingle = true;
}
if (tag === 'IF' || tag === 'ELSE' || tag === 'SWITCH' || tag === 'TRY') {

View File

@ -155,7 +155,7 @@ class exports.Rewriter
@detectEnd i + 1, (token, i) ->
[tag] = token
return yes if not seenSingle and token.fromThen
seenSingle = yes if tag in ['IF', 'ELSE', '->', '=>']
seenSingle = yes if tag in ['IF', 'ELSE', 'CATCH', '->', '=>']
seenControl = yes if tag in ['IF', 'ELSE', 'SWITCH', 'TRY']
return yes if tag in ['.', '?.', '::'] and @tag(i - 1) is 'OUTDENT'
not token.generated and @tag(i - 1) isnt ',' and (tag in IMPLICIT_END or

View File

@ -476,6 +476,10 @@ test "implicit call against control structures", ->
'caught'
eq result, 'caught'
save try doesnt(exist) catch error then 'caught2'
eq result, 'caught2'