Fixed issue where parser improperly parses a function declaration with no identifier.

This commit is contained in:
Daniel Rosenwasser 2014-09-17 15:28:41 -07:00
parent d6888b2834
commit e69b9e6362
4 changed files with 12 additions and 9 deletions

View File

@ -5379,6 +5379,10 @@ module ts {
var isConstructor = (symbol.flags & SymbolFlags.Constructor) !== 0;
function reportImplementationExpectedError(node: FunctionDeclaration): void {
if (node.name && node.name.kind === SyntaxKind.Missing) {
return;
}
var seen = false;
var subsequentNode = forEachChild(node.parent, c => {
if (seen) {

View File

@ -953,7 +953,10 @@ module ts {
return finishNode(node);
}
error(Diagnostics.Identifier_expected);
return <Identifier>createMissingNode();
var node = <Identifier>createMissingNode();
node.text = "";
return node;
}
function parseIdentifier(): Identifier {

View File

@ -1,6 +1,4 @@
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEqualsGreaterThanAfterFunction1.ts (2 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEqualsGreaterThanAfterFunction1.ts (1 errors) ====
function =>
~~
!!! Identifier expected.
!!! Function implementation is missing or not immediately following the declaration.
!!! Identifier expected.

View File

@ -1,4 +1,4 @@
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEqualsGreaterThanAfterFunction2.ts (5 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEqualsGreaterThanAfterFunction2.ts (4 errors) ====
function (a => b;
~
!!! Identifier expected.
@ -7,6 +7,4 @@
~
!!! ',' expected.
!!! ')' expected.
!!! Function implementation is missing or not immediately following the declaration.
!!! ')' expected.