diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d9911b97133..defdde238fb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6599,6 +6599,16 @@ module ts { } function checkPrefixUnaryExpression(node: PrefixUnaryExpression): Type { + // Grammar checking + if (node.parserContextFlags & ParserContextFlags.StrictMode) { + // The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression + // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator + if ((node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) && isEvalOrArgumentsIdentifier(node.operand)) { + reportGrammarErrorOfInvalidUseInStrictMode(node.operand); + } + } + var operandType = checkExpression(node.operand); switch (node.operator) { case SyntaxKind.PlusToken: diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index efa31e19d34..f24bb111db9 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4661,7 +4661,7 @@ module ts { //case SyntaxKind.NumericLiteral: return checkNumericLiteral(node); //case SyntaxKind.Parameter: return checkParameter(node); //case SyntaxKind.PostfixUnaryExpression: return checkPostfixUnaryExpression(node); - case SyntaxKind.PrefixUnaryExpression: return checkPrefixUnaryExpression(node); + //case SyntaxKind.PrefixUnaryExpression: return checkPrefixUnaryExpression(node); case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: return checkProperty(node); diff --git a/tests/baselines/reference/unaryOperatorsInStrictMode.errors.txt b/tests/baselines/reference/unaryOperatorsInStrictMode.errors.txt index 24af4e340a4..53263e7c2e1 100644 --- a/tests/baselines/reference/unaryOperatorsInStrictMode.errors.txt +++ b/tests/baselines/reference/unaryOperatorsInStrictMode.errors.txt @@ -1,10 +1,10 @@ tests/cases/compiler/unaryOperatorsInStrictMode.ts(3,3): error TS1100: Invalid use of 'eval' in strict mode. -tests/cases/compiler/unaryOperatorsInStrictMode.ts(4,3): error TS1100: Invalid use of 'eval' in strict mode. -tests/cases/compiler/unaryOperatorsInStrictMode.ts(5,3): error TS1100: Invalid use of 'arguments' in strict mode. -tests/cases/compiler/unaryOperatorsInStrictMode.ts(6,3): error TS1100: Invalid use of 'arguments' in strict mode. tests/cases/compiler/unaryOperatorsInStrictMode.ts(3,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/compiler/unaryOperatorsInStrictMode.ts(4,3): error TS1100: Invalid use of 'eval' in strict mode. tests/cases/compiler/unaryOperatorsInStrictMode.ts(4,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/compiler/unaryOperatorsInStrictMode.ts(5,3): error TS1100: Invalid use of 'arguments' in strict mode. tests/cases/compiler/unaryOperatorsInStrictMode.ts(5,3): error TS2304: Cannot find name 'arguments'. +tests/cases/compiler/unaryOperatorsInStrictMode.ts(6,3): error TS1100: Invalid use of 'arguments' in strict mode. tests/cases/compiler/unaryOperatorsInStrictMode.ts(6,3): error TS2304: Cannot find name 'arguments'. tests/cases/compiler/unaryOperatorsInStrictMode.ts(7,1): error TS1100: Invalid use of 'eval' in strict mode. tests/cases/compiler/unaryOperatorsInStrictMode.ts(7,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.