Skip to content

Commit

Permalink
disallow inline chained call after func glyph (#4590)
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Rosse authored and GeoffreyBooth committed Jun 30, 2017
1 parent b1d2061 commit 58c6086
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/coffeescript/rewriter.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/rewriter.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ exports.Rewriter = class Rewriter
for j in [1..2] when @tag(i + j) in ['OUTDENT', 'TERMINATOR', 'FINALLY']
tokens.splice i + j, 0, @indentation()...
return 2 + j
if tag in ['->', '=>'] and @tag(i + 1) in [',', '.']
if tag in ['->', '=>'] and (@tag(i + 1) is ',' or @tag(i + 1) is '.' and token.newLine)
[indent, outdent] = @indentation tokens[i]
tokens.splice i + 1, 0, indent, outdent
return 1
Expand Down
10 changes: 10 additions & 0 deletions test/error_messages.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,16 @@ test 'Bound method called as callback before binding throws runtime error', ->
ok no
d = new Derived

test "#3845/#3446: chain after function glyph (but not inline)", ->
assertErrorFormat '''
a -> .b
''',
'''
[stdin]:1:6: error: unexpected .
a -> .b
^
'''

test "#3906: error for unusual indentation", ->
assertErrorFormat '''
a
Expand Down

0 comments on commit 58c6086

Please sign in to comment.