@@ -4471,8 +4471,8 @@ function parseParams(firstRestricted) {
4471
4471
} ;
4472
4472
}
4473
4473
4474
- function parseFunctionDeclaration ( ) {
4475
- var id , body , token , tmp , firstRestricted , message , previousStrict , previousYieldAllowed , generator ,
4474
+ function parseFunctionDeclaration ( identifierIsOptional ) {
4475
+ var id = null , body , token , tmp , firstRestricted , message , previousStrict , previousYieldAllowed , generator ,
4476
4476
marker = markerCreate ( ) ,
4477
4477
allowGenerators = extra . ecmaFeatures . generators ;
4478
4478
@@ -4484,21 +4484,24 @@ function parseFunctionDeclaration() {
4484
4484
generator = true ;
4485
4485
}
4486
4486
4487
- token = lookahead ;
4487
+ if ( ! identifierIsOptional || ! match ( "(" ) ) {
4488
4488
4489
- id = parseVariableIdentifier ( ) ;
4489
+ token = lookahead ;
4490
4490
4491
- if ( strict ) {
4492
- if ( syntax . isRestrictedWord ( token . value ) ) {
4493
- throwErrorTolerant ( token , Messages . StrictFunctionName ) ;
4494
- }
4495
- } else {
4496
- if ( syntax . isRestrictedWord ( token . value ) ) {
4497
- firstRestricted = token ;
4498
- message = Messages . StrictFunctionName ;
4499
- } else if ( syntax . isStrictModeReservedWord ( token . value ) ) {
4500
- firstRestricted = token ;
4501
- message = Messages . StrictReservedWord ;
4491
+ id = parseVariableIdentifier ( ) ;
4492
+
4493
+ if ( strict ) {
4494
+ if ( syntax . isRestrictedWord ( token . value ) ) {
4495
+ throwErrorTolerant ( token , Messages . StrictFunctionName ) ;
4496
+ }
4497
+ } else {
4498
+ if ( syntax . isRestrictedWord ( token . value ) ) {
4499
+ firstRestricted = token ;
4500
+ message = Messages . StrictFunctionName ;
4501
+ } else if ( syntax . isStrictModeReservedWord ( token . value ) ) {
4502
+ firstRestricted = token ;
4503
+ message = Messages . StrictReservedWord ;
4504
+ }
4502
4505
}
4503
4506
}
4504
4507
@@ -4733,9 +4736,8 @@ function parseExportDefaultDeclaration() {
4733
4736
// export default function () {}
4734
4737
// export default class {}
4735
4738
if ( lookahead . value === "function" ) {
4736
- // TODO: change this to declaration once we get FunctionDeclaration with nullable name
4737
- declaration = parseFunctionExpression ( ) ;
4738
- return markerApply ( marker , astNodeFactory . createExportDefaultDeclaration ( declaration ) ) ;
4739
+ declaration = parseFunctionDeclaration ( true ) ;
4740
+ return markerApply ( marker , astNodeFactory . createExportDefaultDeclaration ( declaration ) ) ;
4739
4741
} else if ( lookahead . value === "class" ) {
4740
4742
declaration = parseClassDeclaration ( true ) ;
4741
4743
return markerApply ( marker , astNodeFactory . createExportDefaultDeclaration ( declaration ) ) ;
0 commit comments