From 9e32a5bfa191276fdd2b27d828ba5ed5113efb8f Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Sun, 15 May 2011 15:04:29 -0400 Subject: [PATCH] fixing implicit invocations against inline try/catch. --- lib/rewriter.js | 2 +- src/rewriter.coffee | 2 +- test/function_invocation.coffee | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/rewriter.js b/lib/rewriter.js index 9c33f0f7..d50a222c 100644 --- a/lib/rewriter.js +++ b/lib/rewriter.js @@ -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') { diff --git a/src/rewriter.coffee b/src/rewriter.coffee index 3e1391b5..7cf82588 100644 --- a/src/rewriter.coffee +++ b/src/rewriter.coffee @@ -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 diff --git a/test/function_invocation.coffee b/test/function_invocation.coffee index d150735b..963faca8 100644 --- a/test/function_invocation.coffee +++ b/test/function_invocation.coffee @@ -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'