Skip to content

Commit 3c2196b

Browse files
author
Yui T
committed
Address code review
1 parent a60cf02 commit 3c2196b

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11925,7 +11925,8 @@ module ts {
1192511925
// GRAMMAR CHECKING
1192611926
function isReservedwordInStrictMode(node: Identifier): boolean {
1192711927
// Check that originalKeywordKind is less than LastFurtureReservedWord to see if an Identifier is a strict-mode reserved word
11928-
return (node.parserContextFlags & ParserContextFlags.StrictMode) && node.originalKeywordKind <= SyntaxKind.LastFutureReservedWord;
11928+
return (node.parserContextFlags & ParserContextFlags.StrictMode) &&
11929+
(node.originalKeywordKind >= SyntaxKind.FirstFutureReservedWord && node.originalKeywordKind <= SyntaxKind.LastFutureReservedWord);
1192911930
}
1193011931

1193111932
function reportStrictModeGrammarErrorInClassDeclaration(identifier: Identifier, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
@@ -12015,16 +12016,8 @@ module ts {
1201512016
// Walk from right to left and report a possible error at each Identifier in QualifiedName
1201612017
// Example:
1201712018
// x1: public.private.package // error at public and private
12018-
let qualifiedName = typeName;
12019-
while (qualifiedName && qualifiedName.kind === SyntaxKind.QualifiedName) {
12020-
checkGrammarTypeNameInStrictMode((<QualifiedName>qualifiedName).right);
12021-
qualifiedName = (<QualifiedName>qualifiedName).left;
12022-
}
12023-
12024-
// Report an error at the last Identifier in QualifiedName
12025-
// Example:
12026-
// x1: public.private.package // error at package
12027-
checkGrammarTypeNameInStrictMode(<Identifier>qualifiedName);
12019+
checkGrammarTypeNameInStrictMode((<QualifiedName>typeName).right);
12020+
checkGrammarTypeReferenceInStrictMode((<QualifiedName>typeName).left);
1202812021
}
1202912022
}
1203012023

@@ -12034,27 +12027,18 @@ module ts {
1203412027
// public // error at public
1203512028
// public.private.package // error at public
1203612029
// B.private.B // no error
12037-
function checkGrammarHeritageClauseElementInStrictMode(expression: Expression) {
12030+
function checkGrammarHeritageClauseElementInStrictMode(expression: PropertyAccessExpression) {
1203812031
// Example:
1203912032
// class C extends public // error at public
1204012033
if (expression && expression.kind === SyntaxKind.Identifier) {
1204112034
return checkGrammarIdentifierInStrictMode(expression);
1204212035
}
1204312036
else if (expression && expression.kind === SyntaxKind.PropertyAccessExpression) {
12044-
let propertyAccessExp = <PropertyAccessExpression>expression;
12045-
1204612037
// Walk from left to right in PropertyAccessExpression until we are at the left most expression
1204712038
// in PropertyAccessExpression. According to grammar production of MemberExpression,
1204812039
// the left component expression is a PrimaryExpression (i.e. Identifier) while the other
1204912040
// component after dots can be IdentifierName.
12050-
while (propertyAccessExp && propertyAccessExp.kind === SyntaxKind.PropertyAccessExpression) {
12051-
propertyAccessExp = <PropertyAccessExpression>propertyAccessExp.expression;
12052-
}
12053-
12054-
// Report strict mode at the property of memberExpression
12055-
// Example:
12056-
// public.private.package // error at public as it is parsed as an Identifier in the PropertyAccessExpression
12057-
checkGrammarIdentifierInStrictMode(propertyAccessExp);
12041+
checkGrammarHeritageClauseElementInStrictMode(<PropertyAccessExpression>expression.expression);
1205812042
}
1205912043

1206012044
}

0 commit comments

Comments
 (0)