@@ -897,12 +897,16 @@ module ts {
897
897
// understand when these values should be changed versus when they should be inherited.
898
898
var strictModeContext = false ;
899
899
var disallowInContext = false ;
900
+ var yieldContext : boolean = false ;
901
+ var generatorParameterContext : boolean = false ;
900
902
var contextFlags : number = 0 ;
901
903
902
904
function updateContextFlags ( ) {
903
905
contextFlags =
904
- ( strictModeContext ? NodeFlags . ParsedInStrictModeContext : 0 ) |
905
- ( disallowInContext ? NodeFlags . ParsedInDisallowInContext : 0 ) ;
906
+ ( strictModeContext ? ParserContextFlags . ParsedInStrictModeContext : 0 ) |
907
+ ( disallowInContext ? ParserContextFlags . ParsedInDisallowInContext : 0 ) |
908
+ ( yieldContext ? ParserContextFlags . ParsedInYieldContext : 0 ) |
909
+ ( generatorParameterContext ? ParserContextFlags . ParsedInGeneratorParameterContext : 0 ) ;
906
910
}
907
911
908
912
function setStrictModeContext ( val : boolean ) {
@@ -3759,7 +3763,7 @@ module ts {
3759
3763
}
3760
3764
3761
3765
function checkBinaryExpression ( node : BinaryExpression ) {
3762
- if ( node . parserContextFlags & NodeFlags . ParsedInStrictModeContext ) {
3766
+ if ( node . parserContextFlags & ParserContextFlags . ParsedInStrictModeContext ) {
3763
3767
if ( isLeftHandSideExpression ( node . left ) && isAssignmentOperator ( node . operator ) ) {
3764
3768
if ( isEvalOrArgumentsIdentifier ( node . left ) ) {
3765
3769
// ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an
@@ -3911,7 +3915,7 @@ module ts {
3911
3915
var colonStart = skipTrivia ( sourceText , node . variable . end ) ;
3912
3916
return grammarErrorAtPos ( colonStart , ":" . length , Diagnostics . Catch_clause_parameter_cannot_have_a_type_annotation ) ;
3913
3917
}
3914
- if ( node . parserContextFlags & NodeFlags . ParsedInStrictModeContext && isEvalOrArgumentsIdentifier ( node . variable ) ) {
3918
+ if ( node . parserContextFlags & ParserContextFlags . ParsedInStrictModeContext && isEvalOrArgumentsIdentifier ( node . variable ) ) {
3915
3919
// It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the
3916
3920
// Catch production is eval or arguments
3917
3921
return reportInvalidUseInStrictMode ( node . variable ) ;
@@ -4031,7 +4035,7 @@ module ts {
4031
4035
}
4032
4036
4033
4037
function checkFunctionName ( name : Node ) {
4034
- if ( name && name . parserContextFlags & NodeFlags . ParsedInStrictModeContext && isEvalOrArgumentsIdentifier ( name ) ) {
4038
+ if ( name && name . parserContextFlags & ParserContextFlags . ParsedInStrictModeContext && isEvalOrArgumentsIdentifier ( name ) ) {
4035
4039
// It is a SyntaxError to use within strict mode code the identifiers eval or arguments as the
4036
4040
// Identifier of a FunctionLikeDeclaration or FunctionExpression or as a formal parameter name(13.1)
4037
4041
return reportInvalidUseInStrictMode ( < Identifier > name ) ;
@@ -4152,7 +4156,7 @@ module ts {
4152
4156
var GetAccessor = 2 ;
4153
4157
var SetAccesor = 4 ;
4154
4158
var GetOrSetAccessor = GetAccessor | SetAccesor ;
4155
- var inStrictMode = ( node . parserContextFlags & NodeFlags . ParsedInStrictModeContext ) !== 0 ;
4159
+ var inStrictMode = ( node . parserContextFlags & ParserContextFlags . ParsedInStrictModeContext ) !== 0 ;
4156
4160
4157
4161
for ( var i = 0 , n = node . properties . length ; i < n ; i ++ ) {
4158
4162
var prop = node . properties [ i ] ;
@@ -4216,7 +4220,7 @@ module ts {
4216
4220
4217
4221
function checkNumericLiteral ( node : LiteralExpression ) : boolean {
4218
4222
if ( node . flags & NodeFlags . OctalLiteral ) {
4219
- if ( node . parserContextFlags & NodeFlags . ParsedInStrictModeContext ) {
4223
+ if ( node . parserContextFlags & ParserContextFlags . ParsedInStrictModeContext ) {
4220
4224
return grammarErrorOnNode ( node , Diagnostics . Octal_literals_are_not_allowed_in_strict_mode ) ;
4221
4225
}
4222
4226
else if ( languageVersion >= ScriptTarget . ES5 ) {
@@ -4360,7 +4364,7 @@ module ts {
4360
4364
// or if its FunctionBody is strict code(11.1.5).
4361
4365
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
4362
4366
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
4363
- if ( node . parserContextFlags & NodeFlags . ParsedInStrictModeContext && isEvalOrArgumentsIdentifier ( node . name ) ) {
4367
+ if ( node . parserContextFlags & ParserContextFlags . ParsedInStrictModeContext && isEvalOrArgumentsIdentifier ( node . name ) ) {
4364
4368
return reportInvalidUseInStrictMode ( node . name ) ;
4365
4369
}
4366
4370
}
@@ -4419,13 +4423,13 @@ module ts {
4419
4423
// The identifier eval or arguments may not appear as the LeftHandSideExpression of an
4420
4424
// Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression
4421
4425
// operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator.
4422
- if ( node . parserContextFlags & NodeFlags . ParsedInStrictModeContext && isEvalOrArgumentsIdentifier ( node . operand ) ) {
4426
+ if ( node . parserContextFlags & ParserContextFlags . ParsedInStrictModeContext && isEvalOrArgumentsIdentifier ( node . operand ) ) {
4423
4427
return reportInvalidUseInStrictMode ( < Identifier > node . operand ) ;
4424
4428
}
4425
4429
}
4426
4430
4427
4431
function checkPrefixOperator ( node : UnaryExpression ) {
4428
- if ( node . parserContextFlags & NodeFlags . ParsedInStrictModeContext ) {
4432
+ if ( node . parserContextFlags & ParserContextFlags . ParsedInStrictModeContext ) {
4429
4433
// The identifier eval or arguments may not appear as the LeftHandSideExpression of an
4430
4434
// Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression
4431
4435
// operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator
@@ -4610,7 +4614,7 @@ module ts {
4610
4614
if ( ! inAmbientContext && ! node . initializer && isConst ( node ) ) {
4611
4615
return grammarErrorOnNode ( node , Diagnostics . const_declarations_must_be_initialized ) ;
4612
4616
}
4613
- if ( node . parserContextFlags & NodeFlags . ParsedInStrictModeContext && isEvalOrArgumentsIdentifier ( node . name ) ) {
4617
+ if ( node . parserContextFlags & ParserContextFlags . ParsedInStrictModeContext && isEvalOrArgumentsIdentifier ( node . name ) ) {
4614
4618
// It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code
4615
4619
// and its Identifier is eval or arguments
4616
4620
return reportInvalidUseInStrictMode ( node . name ) ;
@@ -4672,7 +4676,7 @@ module ts {
4672
4676
}
4673
4677
4674
4678
function checkWithStatement ( node : WithStatement ) : boolean {
4675
- if ( node . parserContextFlags & NodeFlags . ParsedInStrictModeContext ) {
4679
+ if ( node . parserContextFlags & ParserContextFlags . ParsedInStrictModeContext ) {
4676
4680
// Strict mode code may not include a WithStatement. The occurrence of a WithStatement in such
4677
4681
// a context is an
4678
4682
return grammarErrorOnFirstToken ( node , Diagnostics . with_statements_are_not_allowed_in_strict_mode ) ;
0 commit comments