Skip to content

Commit 7dbdca8

Browse files
helixbassGeoffreyBooth
authored andcommitted
Allow implicit call with class with no body (#5053)
* allow implicit call with class with no body * more tests
1 parent 8e66ae4 commit 7dbdca8

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

lib/coffeescript/rewriter.js

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

src/rewriter.coffee

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,8 @@ exports.Rewriter = class Rewriter
379379
else if inImplicitObject() and tag is 'TERMINATOR' and prevTag isnt ',' and
380380
not (startsLine and @looksObjectish(i + 1))
381381
endImplicitObject()
382+
else if inImplicitControl() and tokens[stackTop()[1]][0] is 'CLASS' and tag is 'TERMINATOR'
383+
stack.pop()
382384
else
383385
break
384386

test/function_invocation.coffee

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,3 +903,24 @@ test "#4473: variable scope in chained calls", ->
903903

904904
obj.foo({f} = {f: 1}).bar(-> f = 5)
905905
eq f, 5
906+
907+
test "#5052: implicit call of class with no body", ->
908+
doesNotThrow -> CoffeeScript.compile 'f class'
909+
doesNotThrow -> CoffeeScript.compile 'f class A'
910+
doesNotThrow -> CoffeeScript.compile 'f class A extends B'
911+
912+
f = (args...) -> args
913+
a = 1
914+
915+
[klass, shouldBeA] = f class A, a
916+
eq shouldBeA, a
917+
918+
[shouldBeA] = f a, class A
919+
eq shouldBeA, a
920+
921+
[obj, klass, shouldBeA] =
922+
f
923+
b: 1
924+
class A
925+
a
926+
eq shouldBeA, a

0 commit comments

Comments
 (0)