Skip to content

Commit ca0ac81

Browse files
helixbassGeoffreyBooth
authored andcommitted
parse array ending in empty function (#5200)
1 parent f4fcf65 commit ca0ac81

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

lib/coffeescript/rewriter.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rewriter.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ exports.Rewriter = class Rewriter
618618
for j in [1..2] when @tag(i + j) in ['OUTDENT', 'TERMINATOR', 'FINALLY']
619619
tokens.splice i + j, 0, @indentation()...
620620
return 2 + j
621-
if tag in ['->', '=>'] and (@tag(i + 1) is ',' or @tag(i + 1) is '.' and token.newLine)
621+
if tag in ['->', '=>'] and (@tag(i + 1) in [',', ']'] or @tag(i + 1) is '.' and token.newLine)
622622
[indent, outdent] = @indentation tokens[i]
623623
tokens.splice i + 1, 0, indent, outdent
624624
return 1

test/functions.coffee

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,3 +497,10 @@ test "#4657: destructured array parameters", ->
497497
test "#5128: default parameters of function in binary operation", ->
498498
foo = yes or (a, b = {}) -> null
499499
eq foo, yes
500+
501+
test "#5121: array end bracket after function glyph", ->
502+
a = [->]
503+
eq a.length, 1
504+
505+
b = [c: ->]
506+
eq b.length, 1

0 commit comments

Comments
 (0)