Skip to content

Commit 0a03943

Browse files
committed
Merge remote-tracking branch 'upstream/master'
* upstream/master: Do not add reexported names to the exportSpecifiers list of moduleinfo (microsoft#39213) Update user baselines (microsoft#39214) Leverage syntax cursor as part of reparse (microsoft#39216) Update failed test tracking to support Mocha 6+ (microsoft#39211) Update user baselines (microsoft#39196) LEGO: check in for master to temporary branch. # Conflicts: # src/compiler/parser.ts
2 parents 12d86dc + 7893c9f commit 0a03943

File tree

112 files changed

+1241
-1149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+1241
-1149
lines changed

scripts/build/tests.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,23 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode,
7777
// timeout normally isn"t necessary but Travis-CI has been timing out on compiler baselines occasionally
7878
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
7979
if (!runInParallel) {
80-
args.push(failed ? "scripts/run-failed-tests.js" : mochaJs);
80+
args.push(mochaJs);
8181
args.push("-R", "scripts/failed-tests");
8282
args.push("-O", '"reporter=' + reporter + (keepFailed ? ",keepFailed=true" : "") + '"');
8383
if (tests) {
8484
args.push("-g", `"${tests}"`);
8585
}
86+
if (failed) {
87+
const grep = fs.readFileSync(".failed-tests", "utf8")
88+
.split(/\r?\n/g)
89+
.map(test => test.trim())
90+
.filter(test => test.length > 0)
91+
.map(regExpEscape)
92+
.join("|");
93+
const file = path.join(os.tmpdir(), ".failed-tests.json");
94+
fs.writeFileSync(file, JSON.stringify({ grep }), "utf8");
95+
args.push("--config", file);
96+
}
8697
if (colors) {
8798
args.push("--colors");
8899
}
@@ -203,3 +214,7 @@ function restoreSavedNodeEnv() {
203214
function deleteTemporaryProjectOutput() {
204215
return del(path.join(exports.localBaseline, "projectOutput/"));
205216
}
217+
218+
function regExpEscape(text) {
219+
return text.replace(/[.*+?^${}()|\[\]\\]/g, '\\$&');
220+
}

scripts/run-failed-tests.js

Lines changed: 0 additions & 97 deletions
This file was deleted.

src/compiler/binder.ts

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,20 +2127,39 @@ namespace ts {
21272127
}
21282128

21292129
// The binder visits every node in the syntax tree so it is a convenient place to perform a single localized
2130-
// check for reserved words used as identifiers in strict mode code.
2131-
function checkStrictModeIdentifier(node: Identifier) {
2132-
if (inStrictMode &&
2133-
node.originalKeywordKind! >= SyntaxKind.FirstFutureReservedWord &&
2134-
node.originalKeywordKind! <= SyntaxKind.LastFutureReservedWord &&
2135-
!isIdentifierName(node) &&
2130+
// check for reserved words used as identifiers in strict mode code, as well as `yield` or `await` in
2131+
// [Yield] or [Await] contexts, respectively.
2132+
function checkContextualIdentifier(node: Identifier) {
2133+
// Report error only if there are no parse errors in file
2134+
if (!file.parseDiagnostics.length &&
21362135
!(node.flags & NodeFlags.Ambient) &&
2137-
!(node.flags & NodeFlags.JSDoc)) {
2136+
!(node.flags & NodeFlags.JSDoc) &&
2137+
!isIdentifierName(node)) {
21382138

2139-
// Report error only if there are no parse errors in file
2140-
if (!file.parseDiagnostics.length) {
2139+
// strict mode identifiers
2140+
if (inStrictMode &&
2141+
node.originalKeywordKind! >= SyntaxKind.FirstFutureReservedWord &&
2142+
node.originalKeywordKind! <= SyntaxKind.LastFutureReservedWord) {
21412143
file.bindDiagnostics.push(createDiagnosticForNode(node,
21422144
getStrictModeIdentifierMessage(node), declarationNameToString(node)));
21432145
}
2146+
else if (node.originalKeywordKind === SyntaxKind.AwaitKeyword) {
2147+
if (isExternalModule(file) && isInTopLevelContext(node)) {
2148+
file.bindDiagnostics.push(createDiagnosticForNode(node,
2149+
Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module,
2150+
declarationNameToString(node)));
2151+
}
2152+
else if (node.flags & NodeFlags.AwaitContext) {
2153+
file.bindDiagnostics.push(createDiagnosticForNode(node,
2154+
Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here,
2155+
declarationNameToString(node)));
2156+
}
2157+
}
2158+
else if (node.originalKeywordKind === SyntaxKind.YieldKeyword && node.flags & NodeFlags.YieldContext) {
2159+
file.bindDiagnostics.push(createDiagnosticForNode(node,
2160+
Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here,
2161+
declarationNameToString(node)));
2162+
}
21442163
}
21452164
}
21462165

@@ -2455,7 +2474,7 @@ namespace ts {
24552474
if (currentFlow && (isExpression(node) || parent.kind === SyntaxKind.ShorthandPropertyAssignment)) {
24562475
node.flowNode = currentFlow;
24572476
}
2458-
return checkStrictModeIdentifier(<Identifier>node);
2477+
return checkContextualIdentifier(<Identifier>node);
24592478
case SyntaxKind.SuperKeyword:
24602479
node.flowNode = currentFlow;
24612480
break;

src/compiler/checker.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28560,11 +28560,6 @@ namespace ts {
2856028560
return undefinedWideningType;
2856128561
}
2856228562

28563-
function isInTopLevelContext(node: Node) {
28564-
const container = getThisContainer(node, /*includeArrowFunctions*/ true);
28565-
return isSourceFile(container);
28566-
}
28567-
2856828563
function checkAwaitExpression(node: AwaitExpression): Type {
2856928564
// Grammar checking
2857028565
if (produceDiagnostics) {
@@ -35171,7 +35166,6 @@ namespace ts {
3517135166
}
3517235167

3517335168
function checkImportBinding(node: ImportEqualsDeclaration | ImportClause | NamespaceImport | ImportSpecifier) {
35174-
checkGrammarAwaitIdentifier(node.name);
3517535169
checkCollisionWithRequireExportsInGeneratedCode(node, node.name!);
3517635170
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name!);
3517735171
checkAliasSymbol(node);
@@ -37937,31 +37931,19 @@ namespace ts {
3793737931
return false;
3793837932
}
3793937933

37940-
function checkGrammarAwaitIdentifier(name: Identifier | undefined): boolean {
37941-
if (name && isIdentifier(name) && name.originalKeywordKind === SyntaxKind.AwaitKeyword && isInTopLevelContext(name.parent)) {
37942-
const file = getSourceFileOfNode(name);
37943-
if (!file.isDeclarationFile && isExternalModule(file)) {
37944-
return grammarErrorOnNode(name, Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, idText(name));
37945-
}
37946-
}
37947-
return false;
37948-
}
37949-
3795037934
function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration | MethodSignature): boolean {
3795137935
// Prevent cascading error by short-circuit
3795237936
const file = getSourceFileOfNode(node);
3795337937
return checkGrammarDecoratorsAndModifiers(node) ||
3795437938
checkGrammarTypeParameterList(node.typeParameters, file) ||
37955-
(isFunctionDeclaration(node) && checkGrammarAwaitIdentifier(node.name)) ||
3795637939
checkGrammarParameterList(node.parameters) ||
3795737940
checkGrammarArrowFunction(node, file) ||
3795837941
(isFunctionLikeDeclaration(node) && checkGrammarForUseStrictSimpleParameterList(node));
3795937942
}
3796037943

3796137944
function checkGrammarClassLikeDeclaration(node: ClassLikeDeclaration): boolean {
3796237945
const file = getSourceFileOfNode(node);
37963-
return (isClassDeclaration(node) && checkGrammarAwaitIdentifier(node.name)) ||
37964-
checkGrammarClassDeclarationHeritageClauses(node) ||
37946+
return checkGrammarClassDeclarationHeritageClauses(node) ||
3796537947
checkGrammarTypeParameterList(node.typeParameters, file);
3796637948
}
3796737949

@@ -38604,10 +38586,6 @@ namespace ts {
3860438586
}
3860538587
}
3860638588

38607-
if (isIdentifier(node.name) && checkGrammarAwaitIdentifier(node.name)) {
38608-
return true;
38609-
}
38610-
3861138589
if (node.dotDotDotToken && node.initializer) {
3861238590
// Error on equals token which immediately precedes the initializer
3861338591
return grammarErrorAtPos(node, node.initializer.pos - 1, 1, Diagnostics.A_rest_element_cannot_have_an_initializer);
@@ -38671,9 +38649,6 @@ namespace ts {
3867138649
}
3867238650
}
3867338651
}
38674-
if (isIdentifier(node.name) && checkGrammarAwaitIdentifier(node.name)) {
38675-
return true;
38676-
}
3867738652

3867838653
if (node.exclamationToken && (node.parent.parent.kind !== SyntaxKind.VariableStatement || !node.type || node.initializer || node.flags & NodeFlags.Ambient)) {
3867938654
return grammarErrorOnNode(node.exclamationToken, Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation);

0 commit comments

Comments
 (0)