From 2f075a1c06f900321b97130bf7c0f9dab9055c40 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 24 Nov 2014 22:41:55 -0800 Subject: [PATCH] Fix parsing of function expression names. --- src/services/syntax/parser.ts | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/src/services/syntax/parser.ts b/src/services/syntax/parser.ts index 37e25579bf1..6b03a4721c1 100644 --- a/src/services/syntax/parser.ts +++ b/src/services/syntax/parser.ts @@ -1018,30 +1018,6 @@ module TypeScript.Parser { // no need to do anything special if we're not in the [Yield] context. return func(); } - - function enterGeneratorParameterContextAnd(func: () => T): T { - if (generatorParameterContext) { - // no need to do anything special if we're already in the [GeneratorParameter] context - return func(); - } - - setGeneratorParameterContext(true); - var result = func(); - setGeneratorParameterContext(false); - return result; - } - - function exitGeneratorParameterContextAnd(func: () => T): T { - if (generatorParameterContext) { - setGeneratorParameterContext(false); - var result = func(); - setGeneratorParameterContext(true); - return result; - } - - // no need to do anything special if we're not in the [GeneratorParameter] context - return func(); - } function tryParseEnumElementEqualsValueClause(): EqualsValueClauseSyntax { return isEqualsValueClause(/*inParameter*/ false) ? allowInAnd(parseEqualsValueClause) : undefined; @@ -2410,8 +2386,6 @@ module TypeScript.Parser { // precedence than 'comma'. Otherwise we'll get: "var a = (1, (b = 2))", instead of // "var a = (1), b = (2)"); function tryParseAssignmentExpressionOrHigherWorker(force: boolean): IExpressionSyntax { - // Augmented by TypeScript: - // // AssignmentExpression[in,yield]: // 1) ConditionalExpression[?in,?yield] // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] @@ -3033,12 +3007,14 @@ module TypeScript.Parser { function parseFunctionExpressionWorker(functionKeyword: ISyntaxToken, asteriskToken: ISyntaxToken) { // GeneratorExpression : // function * BindingIdentifier[Yield]opt (FormalParameters[Yield, GeneratorParameter]) { GeneratorBody[Yield] } + // FunctionExpression: + // function BindingIdentifieropt(FormalParameters) { FunctionBody } var isGenerator = asteriskToken !== undefined; return new FunctionExpressionSyntax(contextFlags, functionKeyword, asteriskToken, - enterYieldContextAnd(eatOptionalIdentifierToken), + asteriskToken ? enterYieldContextAnd(eatOptionalIdentifierToken) : eatOptionalIdentifierToken(), parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yield:*/ isGenerator, /*generatorParameter:*/ isGenerator), parseFunctionBody(isGenerator)); }