From df97effb9cab38eba4dc13da5a59f644b630e4b8 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Sat, 10 Apr 2010 18:56:46 -0400 Subject: [PATCH] fixing implicit-call-in-function-in-parens bug. --- lib/rewriter.js | 2 +- src/rewriter.coffee | 2 +- test/test_functions.coffee | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/rewriter.js b/lib/rewriter.js index 5adc164a..5b278246 100644 --- a/lib/rewriter.js +++ b/lib/rewriter.js @@ -162,7 +162,7 @@ stack[stack.length - 1] += last; } open = stack[stack.length - 1] > 0; - if (!(typeof post !== "undefined" && post !== null) || (start_parens > parens) || (parens === 0 && include(IMPLICIT_END, tag))) { + if (!(typeof post !== "undefined" && post !== null) || (start_parens > parens) || (start_parens === parens && include(IMPLICIT_END, tag))) { if (tag === 'INDENT' && prev && include(IMPLICIT_BLOCK, prev[0])) { return 1; } diff --git a/src/rewriter.coffee b/src/rewriter.coffee index 9965f585..40b57390 100644 --- a/src/rewriter.coffee +++ b/src/rewriter.coffee @@ -124,7 +124,7 @@ exports.Rewriter: class Rewriter last: stack.pop() stack[stack.length - 1]: + last open: stack[stack.length - 1] > 0 - if !post? or (start_parens > parens) or (parens is 0 and include IMPLICIT_END, tag) + if !post? or (start_parens > parens) or (start_parens is parens and include IMPLICIT_END, tag) return 1 if tag is 'INDENT' and prev and include IMPLICIT_BLOCK, prev[0] return 1 if tag is 'OUTDENT' and token.generated if open or tag is 'INDENT' diff --git a/test/test_functions.coffee b/test/test_functions.coffee index 2fde21f5..6c8c2bc4 100644 --- a/test/test_functions.coffee +++ b/test/test_functions.coffee @@ -129,3 +129,12 @@ result: (f 1).toString() .length ok result is 1 + + +# Test implicit calls in functions in parens: +result: ((val) -> + [].push val + val +)(10) + +ok result is 10