Allow implicit call with class with no body (#5053)
* allow implicit call with class with no body * more tests
This commit is contained in:
parent
8e66ae404e
commit
7dbdca8c54
|
@ -542,6 +542,8 @@
|
|||
// the continuation of an object.
|
||||
} else if (inImplicitObject() && tag === 'TERMINATOR' && prevTag !== ',' && !(startsLine && this.looksObjectish(i + 1))) {
|
||||
endImplicitObject();
|
||||
} else if (inImplicitControl() && tokens[stackTop()[1]][0] === 'CLASS' && tag === 'TERMINATOR') {
|
||||
stack.pop();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -379,6 +379,8 @@ exports.Rewriter = class Rewriter
|
|||
else if inImplicitObject() and tag is 'TERMINATOR' and prevTag isnt ',' and
|
||||
not (startsLine and @looksObjectish(i + 1))
|
||||
endImplicitObject()
|
||||
else if inImplicitControl() and tokens[stackTop()[1]][0] is 'CLASS' and tag is 'TERMINATOR'
|
||||
stack.pop()
|
||||
else
|
||||
break
|
||||
|
||||
|
|
|
@ -903,3 +903,24 @@ test "#4473: variable scope in chained calls", ->
|
|||
|
||||
obj.foo({f} = {f: 1}).bar(-> f = 5)
|
||||
eq f, 5
|
||||
|
||||
test "#5052: implicit call of class with no body", ->
|
||||
doesNotThrow -> CoffeeScript.compile 'f class'
|
||||
doesNotThrow -> CoffeeScript.compile 'f class A'
|
||||
doesNotThrow -> CoffeeScript.compile 'f class A extends B'
|
||||
|
||||
f = (args...) -> args
|
||||
a = 1
|
||||
|
||||
[klass, shouldBeA] = f class A, a
|
||||
eq shouldBeA, a
|
||||
|
||||
[shouldBeA] = f a, class A
|
||||
eq shouldBeA, a
|
||||
|
||||
[obj, klass, shouldBeA] =
|
||||
f
|
||||
b: 1
|
||||
class A
|
||||
a
|
||||
eq shouldBeA, a
|
||||
|
|
Loading…
Reference in New Issue