Fixed a function expression parsing issue

Also uncovered a yet-to-be-fixed issue when immediately calling a returned function
This commit is contained in:
dcodeIO
2018-03-12 19:39:05 +01:00
parent 7870e3ac18
commit c93f0bb1fe
10 changed files with 51 additions and 65 deletions

View File

@ -2810,11 +2810,14 @@ export class Parser extends DiagnosticEmitter {
if (!expr) return null;
var startPos = expr.range.start;
// CallExpression
var typeArguments = this.tryParseTypeArgumentsBeforeArguments(tn); // skips '(' on success
// there might be better ways to distinguish a LESSTHAN from a CALL with type arguments
if (typeArguments || tn.skip(Token.OPENPAREN)) {
var args = this.parseArguments(tn);
// CallExpression with type arguments
var typeArguments: CommonTypeNode[] | null;
while (
// there might be better ways to distinguish a LESSTHAN from a CALL with type arguments
(typeArguments = this.tryParseTypeArgumentsBeforeArguments(tn)) ||
tn.skip(Token.OPENPAREN)
) {
let args = this.parseArguments(tn);
if (!args) return null;
expr = Node.createCallExpression(expr, typeArguments, args, tn.range(startPos, tn.pos));
}