From 40d2761bd88593ef1e341462e0df53c08b8849eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20H=C3=A4fner?= Date: Thu, 18 Apr 2013 01:20:28 +0200 Subject: [PATCH] Fixes #2916 -- implicit calls with preceding herecomment --- lib/coffee-script/rewriter.js | 2 +- src/rewriter.coffee | 2 +- test/comments.coffee | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/coffee-script/rewriter.js b/lib/coffee-script/rewriter.js index 12d9ab08..a5b6cae1 100644 --- a/lib/coffee-script/rewriter.js +++ b/lib/coffee-script/rewriter.js @@ -273,7 +273,7 @@ startImplicitCall(i + 1); return forward(2); } - if (this.matchTags(i, IMPLICIT_FUNC, 'INDENT', null, ':') && !this.findTagsBackwards(i, ['CLASS', 'EXTENDS', 'IF', 'CATCH', 'SWITCH', 'LEADING_WHEN', 'FOR', 'WHILE', 'UNTIL'])) { + if (__indexOf.call(IMPLICIT_FUNC, tag) >= 0 && this.matchTags(i + 1, 'INDENT', null, ':') && !this.findTagsBackwards(i, ['CLASS', 'EXTENDS', 'IF', 'CATCH', 'SWITCH', 'LEADING_WHEN', 'FOR', 'WHILE', 'UNTIL'])) { startImplicitCall(i + 1); stack.push(['INDENT', i + 2]); return forward(3); diff --git a/src/rewriter.coffee b/src/rewriter.coffee index 9231d959..bd638376 100644 --- a/src/rewriter.coffee +++ b/src/rewriter.coffee @@ -251,7 +251,7 @@ class exports.Rewriter # which is probably always unintended. # Furthermore don't allow this in literal arrays, as # that creates grammatical ambiguities. - if @matchTags(i, IMPLICIT_FUNC, 'INDENT', null, ':') and + if tag in IMPLICIT_FUNC and @matchTags(i + 1, 'INDENT', null, ':') and not @findTagsBackwards(i, ['CLASS', 'EXTENDS', 'IF', 'CATCH', 'SWITCH', 'LEADING_WHEN', 'FOR', 'WHILE', 'UNTIL']) startImplicitCall i + 1 diff --git a/test/comments.coffee b/test/comments.coffee index d3f8aec7..bd1ac912 100644 --- a/test/comments.coffee +++ b/test/comments.coffee @@ -205,3 +205,9 @@ test "block comments inside class bodies", -> test "#2037: herecomments shouldn't imply line terminators", -> do (-> ### ###; fail) + +test "#2916: block comment before implicit call with implicit object", -> + fn = (obj) -> ok obj.a + ### ### + fn + a: yes