@@ -7734,7 +7734,7 @@ namespace ts {
7734
7734
// Grammar checking
7735
7735
let hasGrammarError = checkGrammarFunctionLikeDeclaration(node);
7736
7736
if (!hasGrammarError && node.kind === SyntaxKind.FunctionExpression) {
7737
- checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node);
7737
+ checkGrammarForGenerator(node);
7738
7738
}
7739
7739
7740
7740
// The identityMapper object is used to indicate that function expressions are wildcards
@@ -7891,14 +7891,7 @@ namespace ts {
7891
7891
}
7892
7892
7893
7893
function checkDeleteExpression(node: DeleteExpression): Type {
7894
- // Grammar checking
7895
- if (node.parserContextFlags & ParserContextFlags.StrictMode && node.expression.kind === SyntaxKind.Identifier) {
7896
- // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its
7897
- // UnaryExpression is a direct reference to a variable, function argument, or function name
7898
- grammarErrorOnNode(node.expression, Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode);
7899
- }
7900
-
7901
- let operandType = checkExpression(node.expression);
7894
+ checkExpression(node.expression);
7902
7895
return booleanType;
7903
7896
}
7904
7897
@@ -7913,14 +7906,6 @@ namespace ts {
7913
7906
}
7914
7907
7915
7908
function checkPrefixUnaryExpression(node: PrefixUnaryExpression): Type {
7916
- // Grammar checking
7917
- // The identifier eval or arguments may not appear as the LeftHandSideExpression of an
7918
- // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression
7919
- // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator
7920
- if ((node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken)) {
7921
- checkGrammarEvalOrArgumentsInStrictMode(node, <Identifier>node.operand);
7922
- }
7923
-
7924
7909
let operandType = checkExpression(node.operand);
7925
7910
switch (node.operator) {
7926
7911
case SyntaxKind.PlusToken:
@@ -7947,12 +7932,6 @@ namespace ts {
7947
7932
}
7948
7933
7949
7934
function checkPostfixUnaryExpression(node: PostfixUnaryExpression): Type {
7950
- // Grammar checking
7951
- // The identifier eval or arguments may not appear as the LeftHandSideExpression of an
7952
- // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression
7953
- // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator.
7954
- checkGrammarEvalOrArgumentsInStrictMode(node, <Identifier>node.operand);
7955
-
7956
7935
let operandType = checkExpression(node.operand);
7957
7936
let ok = checkArithmeticOperandType(node.operand, operandType, Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type);
7958
7937
if (ok) {
@@ -8132,13 +8111,6 @@ namespace ts {
8132
8111
}
8133
8112
8134
8113
function checkBinaryExpression(node: BinaryExpression, contextualMapper?: TypeMapper) {
8135
- // Grammar checking
8136
- if (isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operatorToken.kind)) {
8137
- // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an
8138
- // Assignment operator(11.13) or of a PostfixExpression(11.3)
8139
- checkGrammarEvalOrArgumentsInStrictMode(node, <Identifier>node.left);
8140
- }
8141
-
8142
8114
let operator = node.operatorToken.kind;
8143
8115
if (operator === SyntaxKind.EqualsToken && (node.left.kind === SyntaxKind.ObjectLiteralExpression || node.left.kind === SyntaxKind.ArrayLiteralExpression)) {
8144
8116
return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper);
@@ -8580,11 +8552,9 @@ namespace ts {
8580
8552
// It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the
8581
8553
// Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code
8582
8554
// or if its FunctionBody is strict code(11.1.5).
8583
- // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
8584
- // strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
8585
8555
8586
8556
// Grammar checking
8587
- checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, <Identifier>node.name) ;
8557
+ checkGrammarDecorators(node) || checkGrammarModifiers(node);
8588
8558
8589
8559
checkVariableLikeDeclaration(node);
8590
8560
let func = getContainingFunction(node);
@@ -9476,9 +9446,7 @@ namespace ts {
9476
9446
9477
9447
function checkFunctionDeclaration(node: FunctionDeclaration): void {
9478
9448
if (produceDiagnostics) {
9479
- checkFunctionLikeDeclaration(node) ||
9480
- checkGrammarFunctionName(node.name) ||
9481
- checkGrammarForGenerator(node);
9449
+ checkFunctionLikeDeclaration(node) || checkGrammarForGenerator(node);
9482
9450
9483
9451
checkCollisionWithCapturedSuperVariable(node, node.name);
9484
9452
checkCollisionWithCapturedThisVariable(node, node.name);
@@ -10305,12 +10273,7 @@ namespace ts {
10305
10273
}
10306
10274
10307
10275
function checkWithStatement(node: WithStatement) {
10308
- // Grammar checking for withStatement
10309
- if (!checkGrammarStatementInAmbientContext(node)) {
10310
- if (node.parserContextFlags & ParserContextFlags.StrictMode) {
10311
- grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode);
10312
- }
10313
- }
10276
+ checkGrammarStatementInAmbientContext(node);
10314
10277
10315
10278
checkExpression(node.expression);
10316
10279
error(node.expression, Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any);
@@ -10414,10 +10377,6 @@ namespace ts {
10414
10377
grammarErrorOnNode(localSymbol.valueDeclaration, Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName);
10415
10378
}
10416
10379
}
10417
-
10418
- // It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the
10419
- // Catch production is eval or arguments
10420
- checkGrammarEvalOrArgumentsInStrictMode(node, <Identifier>catchClause.variableDeclaration.name);
10421
10380
}
10422
10381
}
10423
10382
@@ -13022,11 +12981,6 @@ namespace ts {
13022
12981
}
13023
12982
}
13024
12983
13025
- function checkGrammarFunctionName(name: Node) {
13026
- // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a strict mode FunctionDeclaration or FunctionExpression (13.1))
13027
- return checkGrammarEvalOrArgumentsInStrictMode(name, <Identifier>name);
13028
- }
13029
-
13030
12984
function checkGrammarForInvalidQuestionMark(node: Declaration, questionToken: Node, message: DiagnosticMessage): boolean {
13031
12985
if (questionToken) {
13032
12986
return grammarErrorOnNode(questionToken, message);
@@ -13039,7 +12993,6 @@ namespace ts {
13039
12993
let GetAccessor = 2;
13040
12994
let SetAccesor = 4;
13041
12995
let GetOrSetAccessor = GetAccessor | SetAccesor;
13042
- let inStrictMode = (node.parserContextFlags & ParserContextFlags.StrictMode) !== 0;
13043
12996
13044
12997
for (let prop of node.properties) {
13045
12998
let name = prop.name;
@@ -13086,9 +13039,7 @@ namespace ts {
13086
13039
else {
13087
13040
let existingKind = seen[(<Identifier>name).text];
13088
13041
if (currentKind === Property && existingKind === Property) {
13089
- if (inStrictMode) {
13090
- grammarErrorOnNode(name, Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode);
13091
- }
13042
+ continue;
13092
13043
}
13093
13044
else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) {
13094
13045
if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) {
@@ -13311,9 +13262,6 @@ namespace ts {
13311
13262
return grammarErrorAtPos(getSourceFileOfNode(node), node.initializer.pos - 1, 1, Diagnostics.A_rest_element_cannot_have_an_initializer);
13312
13263
}
13313
13264
}
13314
- // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code
13315
- // and its Identifier is eval or arguments
13316
- return checkGrammarEvalOrArgumentsInStrictMode(node, <Identifier>node.name);
13317
13265
}
13318
13266
13319
13267
function checkGrammarVariableDeclaration(node: VariableDeclaration) {
@@ -13345,8 +13293,7 @@ namespace ts {
13345
13293
13346
13294
// It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code
13347
13295
// and its Identifier is eval or arguments
13348
- return (checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name)) ||
13349
- checkGrammarEvalOrArgumentsInStrictMode(node, <Identifier>node.name);
13296
+ return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name);
13350
13297
}
13351
13298
13352
13299
function checkGrammarNameInLetOrConstDeclarations(name: Identifier | BindingPattern): boolean {
@@ -13485,25 +13432,6 @@ namespace ts {
13485
13432
}
13486
13433
}
13487
13434
13488
- function checkGrammarEvalOrArgumentsInStrictMode(contextNode: Node, name: Node): boolean {
13489
- if (name && name.kind === SyntaxKind.Identifier) {
13490
- let identifier = <Identifier>name;
13491
- if (contextNode && (contextNode.parserContextFlags & ParserContextFlags.StrictMode) && isEvalOrArgumentsIdentifier(identifier)) {
13492
- // We check first if the name is inside class declaration or class expression; if so give explicit message
13493
- // otherwise report generic error message.
13494
- let message = getAncestor(identifier, SyntaxKind.ClassDeclaration) || getAncestor(identifier, SyntaxKind.ClassExpression) ?
13495
- Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode :
13496
- Diagnostics.Invalid_use_of_0_in_strict_mode;
13497
- return grammarErrorOnNode(identifier, message, declarationNameToString(identifier));
13498
- }
13499
- }
13500
- }
13501
-
13502
- function isEvalOrArgumentsIdentifier(node: Node): boolean {
13503
- return node.kind === SyntaxKind.Identifier &&
13504
- ((<Identifier>node).text === "eval" || (<Identifier>node).text === "arguments");
13505
- }
13506
-
13507
13435
function checkGrammarConstructorTypeParameters(node: ConstructorDeclaration) {
13508
13436
if (node.typeParameters) {
13509
13437
return grammarErrorAtPos(getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
@@ -13613,13 +13541,8 @@ namespace ts {
13613
13541
13614
13542
function checkGrammarNumericLiteral(node: Identifier): boolean {
13615
13543
// Grammar checking
13616
- if (node.flags & NodeFlags.OctalLiteral) {
13617
- if (node.parserContextFlags & ParserContextFlags.StrictMode) {
13618
- return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode);
13619
- }
13620
- else if (languageVersion >= ScriptTarget.ES5) {
13621
- return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher);
13622
- }
13544
+ if (node.flags & NodeFlags.OctalLiteral && languageVersion >= ScriptTarget.ES5) {
13545
+ return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher);
13623
13546
}
13624
13547
}
13625
13548
0 commit comments