Fixes #2916 -- implicit calls with preceding herecomment

This commit is contained in:
Marc Häfner
2013-04-18 01:20:28 +02:00
parent c785e00a15
commit 40d2761bd8
3 changed files with 8 additions and 2 deletions

View File

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

View File

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

View File

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