Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f8f3148

Browse files
Merge branch 'master' into lessDirectCallsToError
Conflicts: src/compiler/checker.ts src/compiler/diagnosticInformationMap.generated.ts src/compiler/diagnosticMessages.json
2 parents df4f904 + 852d14e commit f8f3148

File tree

162 files changed

+7819
-509
lines changed

Some content is hidden

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

162 files changed

+7819
-509
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ tests/cases/*/*/*.js.map
1111
tests/cases/*/*/*/*.js.map
1212
tests/cases/*/*/*/*/*.js.map
1313
tests/cases/rwc/*
14+
tests/cases/test262/*
1415
tests/cases/perf/*
1516
!tests/cases/webharness/compilerToString.js
1617
test-args.txt
@@ -19,6 +20,7 @@ tests/baselines/local/*
1920
tests/services/baselines/local/*
2021
tests/baselines/prototyping/local/*
2122
tests/baselines/rwc/*
23+
tests/baselines/test262/*
2224
tests/services/baselines/prototyping/local/*
2325
tests/services/browser/typescriptServices.js
2426
scripts/processDiagnosticMessages.d.ts

Jakefile

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ var harnessSources = [
7878
"projectsRunner.ts",
7979
"loggedIO.ts",
8080
"rwcRunner.ts",
81+
"test262Runner.ts",
8182
"runner.ts"
8283
].map(function (f) {
8384
return path.join(harnessDirectory, f);
@@ -91,10 +92,12 @@ var harnessSources = [
9192

9293
var librarySourceMap = [
9394
{ target: "lib.core.d.ts", sources: ["core.d.ts"] },
94-
{ target: "lib.dom.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "dom.generated.d.ts"], },
95-
{ target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "webworker.generated.d.ts"], },
95+
{ target: "lib.dom.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "intl.d.ts", "dom.generated.d.ts"], },
96+
{ target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "intl.d.ts", "webworker.generated.d.ts"], },
9697
{ target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], },
97-
{ target: "lib.d.ts", sources: ["core.d.ts", "extensions.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], },
98+
{ target: "lib.d.ts", sources: ["core.d.ts", "extensions.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], },
99+
{ target: "lib.core.es6.d.ts", sources: ["core.d.ts", "es6.d.ts"]},
100+
{ target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"]},
98101
];
99102

100103
var libraryTargets = librarySourceMap.map(function (f) {
@@ -135,7 +138,6 @@ function concatenateFiles(destinationFile, sourceFiles) {
135138
}
136139

137140
var useDebugMode = true;
138-
var generateDeclarations = false;
139141
var host = (process.env.host || process.env.TYPESCRIPT_HOST || "node");
140142
var compilerFilename = "tsc.js";
141143
/* Compiles a file from a list of sources
@@ -146,7 +148,7 @@ var compilerFilename = "tsc.js";
146148
* @param useBuiltCompiler: true to use the built compiler, false to use the LKG
147149
* @param noOutFile: true to compile without using --out
148150
*/
149-
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile) {
151+
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations) {
150152
file(outFile, prereqs, function() {
151153
var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory;
152154
var options = "-removeComments --module commonjs -noImplicitAny ";
@@ -157,7 +159,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu
157159
if (useDebugMode) {
158160
options += "--preserveConstEnums ";
159161
}
160-
162+
161163
var cmd = host + " " + dir + compilerFilename + " " + options + " ";
162164
cmd = cmd + sources.join(" ") + (!noOutFile ? " -out " + outFile : "");
163165
if (useDebugMode) {
@@ -184,7 +186,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu
184186
fs.unlinkSync(outFile);
185187
console.log("Compilation of " + outFile + " unsuccessful");
186188
});
187-
ex.run();
189+
ex.run();
188190
}, {async: true});
189191
}
190192

@@ -239,7 +241,7 @@ file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson],
239241
ex.addListener("cmdEnd", function() {
240242
complete();
241243
});
242-
ex.run();
244+
ex.run();
243245
}, {async: true})
244246

245247

@@ -252,7 +254,8 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename);
252254
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false);
253255

254256
var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
255-
compileFile(servicesFile, servicesSources, [builtLocalDirectory, copyright].concat(servicesSources), [copyright], /*useBuiltCompiler:*/ true);
257+
var servicesDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
258+
compileFile(servicesFile, servicesSources, [builtLocalDirectory, copyright].concat(servicesSources), [copyright], /*useBuiltCompiler:*/ true, /*noOutFile:*/ false, /*generateDeclarations:*/ true);
256259

257260
// Local target to build the compiler and services
258261
desc("Builds the full compiler and services");
@@ -275,11 +278,6 @@ task("clean", function() {
275278
jake.rmRf(builtDirectory);
276279
});
277280

278-
// generate declarations for compiler and services
279-
desc("Generate declarations for compiler and services");
280-
task("declaration", function() {
281-
generateDeclarations = true;
282-
});
283281

284282
// Generate Markdown spec
285283
var word2mdJs = path.join(scriptsDirectory, "word2md.js");
@@ -314,7 +312,7 @@ task("generate-spec", [specMd])
314312
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
315313
desc("Makes a new LKG out of the built js files");
316314
task("LKG", ["clean", "release", "local"].concat(libraryTargets), function() {
317-
var expectedFiles = [tscFile, servicesFile].concat(libraryTargets);
315+
var expectedFiles = [tscFile, servicesFile, servicesDefinitionsFile].concat(libraryTargets);
318316
var missingFiles = expectedFiles.filter(function (f) {
319317
return !fs.existsSync(f);
320318
});
@@ -346,6 +344,9 @@ var refBaseline = "tests/baselines/reference/";
346344
var localRwcBaseline = "tests/baselines/rwc/local/";
347345
var refRwcBaseline = "tests/baselines/rwc/reference/";
348346

347+
var localTest262Baseline = "tests/baselines/test262/local/";
348+
var refTest262Baseline = "tests/baselines/test262/reference/";
349+
349350
desc("Builds the test infrastructure using the built compiler");
350351
task("tests", ["local", run].concat(libraryTargets));
351352

@@ -514,6 +515,12 @@ task("baseline-accept-rwc", function() {
514515
fs.renameSync(localRwcBaseline, refRwcBaseline);
515516
});
516517

518+
desc("Makes the most recent test262 test results the new baseline, overwriting the old baseline");
519+
task("baseline-accept-test262", function() {
520+
jake.rmRf(refTest262Baseline);
521+
fs.renameSync(localTest262Baseline, refTest262Baseline);
522+
});
523+
517524

518525
// Webhost
519526
var webhostPath = "tests/webhost/webtsc.ts";
@@ -547,7 +554,7 @@ file(loggedIOJsPath, [builtLocalDirectory, loggedIOpath], function() {
547554
jake.rmRf(temp);
548555
complete();
549556
});
550-
ex.run();
557+
ex.run();
551558
}, {async: true});
552559

553560
var instrumenterPath = harnessDirectory + 'instrumenter.ts';

src/compiler/binder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ module ts {
135135
if (node.name) {
136136
node.name.parent = node;
137137
}
138+
138139
// Report errors every position with duplicate declaration
139140
// Report errors on previous encountered declarations
140141
var message = symbol.flags & SymbolFlags.BlockScopedVariable

src/compiler/checker.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,8 @@ module ts {
16131613
return isDeclarationVisible(<Declaration>parent);
16141614

16151615
case SyntaxKind.Property:
1616+
case SyntaxKind.GetAccessor:
1617+
case SyntaxKind.SetAccessor:
16161618
case SyntaxKind.Method:
16171619
if (node.flags & (NodeFlags.Private | NodeFlags.Protected)) {
16181620
// Private/protected properties/methods are not visible
@@ -1627,6 +1629,14 @@ module ts {
16271629
case SyntaxKind.Parameter:
16281630
case SyntaxKind.ModuleBlock:
16291631
case SyntaxKind.TypeParameter:
1632+
case SyntaxKind.FunctionType:
1633+
case SyntaxKind.ConstructorType:
1634+
case SyntaxKind.TypeLiteral:
1635+
case SyntaxKind.TypeReference:
1636+
case SyntaxKind.ArrayType:
1637+
case SyntaxKind.TupleType:
1638+
case SyntaxKind.UnionType:
1639+
case SyntaxKind.ParenthesizedType:
16301640
return isDeclarationVisible(<Declaration>node.parent);
16311641

16321642
// Source file is always visible
@@ -5344,15 +5354,15 @@ module ts {
53445354
var templateExpression = <TemplateExpression>tagExpression.template;
53455355
var lastSpan = lastOrUndefined(templateExpression.templateSpans);
53465356
Debug.assert(lastSpan !== undefined); // we should always have at least one span.
5347-
callIsIncomplete = getFullWidth(lastSpan.literal) === 0 || isUnterminatedTemplateEnd(lastSpan.literal);
5357+
callIsIncomplete = getFullWidth(lastSpan.literal) === 0 || !!lastSpan.literal.isUnterminated;
53485358
}
53495359
else {
53505360
// If the template didn't end in a backtick, or its beginning occurred right prior to EOF,
53515361
// then this might actually turn out to be a TemplateHead in the future;
53525362
// so we consider the call to be incomplete.
53535363
var templateLiteral = <LiteralExpression>tagExpression.template;
53545364
Debug.assert(templateLiteral.kind === SyntaxKind.NoSubstitutionTemplateLiteral);
5355-
callIsIncomplete = isUnterminatedTemplateEnd(templateLiteral);
5365+
callIsIncomplete = !!templateLiteral.isUnterminated;
53565366
}
53575367
}
53585368
else {

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ module ts {
137137
Classes_can_only_extend_a_single_class: { code: 1174, category: DiagnosticCategory.Error, key: "Classes can only extend a single class." },
138138
implements_clause_already_seen: { code: 1175, category: DiagnosticCategory.Error, key: "'implements' clause already seen." },
139139
Interface_declaration_cannot_have_implements_clause: { code: 1176, category: DiagnosticCategory.Error, key: "Interface declaration cannot have 'implements' clause." },
140-
Unexpected_token_expected: { code: 1177, category: DiagnosticCategory.Error, key: "Unexpected token. '{' expected." },
140+
Binary_digit_expected: { code: 1177, category: DiagnosticCategory.Error, key: "Binary digit expected." },
141+
Octal_digit_expected: { code: 1178, category: DiagnosticCategory.Error, key: "Octal digit expected." },
142+
Unexpected_token_expected: { code: 1179, category: DiagnosticCategory.Error, key: "Unexpected token. '{' expected." },
141143
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
142144
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
143145
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },

src/compiler/diagnosticMessages.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,8 @@
483483
"category": "Error",
484484
"code": 1162
485485
},
486-
"'yield' expression must be contained_within a generator declaration.": {
486+
"'yield' expression must be contained_within a generator declaration."
487+
: {
487488
"category": "Error",
488489
"code": 1163
489490
},
@@ -539,10 +540,18 @@
539540
"category": "Error",
540541
"code": 1176
541542
},
542-
"Unexpected token. '{' expected.": {
543+
"Binary digit expected.": {
543544
"category": "Error",
544545
"code": 1177
545546
},
547+
"Octal digit expected.": {
548+
"category": "Error",
549+
"code": 1178
550+
},
551+
"Unexpected token. '{' expected.": {
552+
"category": "Error",
553+
"code": 1179
554+
},
546555

547556
"Duplicate identifier '{0}'.": {
548557
"category": "Error",

src/compiler/emitter.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,12 +1945,28 @@ module ts {
19451945
}
19461946
}
19471947

1948+
function isBinaryOrOctalIntegerLiteral(text: string): boolean {
1949+
if (text.length <= 0) {
1950+
return false;
1951+
}
1952+
1953+
if (text.charCodeAt(1) === CharacterCodes.B || text.charCodeAt(1) === CharacterCodes.b ||
1954+
text.charCodeAt(1) === CharacterCodes.O || text.charCodeAt(1) === CharacterCodes.o) {
1955+
return true;
1956+
}
1957+
return false;
1958+
}
1959+
19481960
function emitLiteral(node: LiteralExpression) {
19491961
var text = getLiteralText();
19501962

19511963
if (compilerOptions.sourceMap && (node.kind === SyntaxKind.StringLiteral || isTemplateLiteralKind(node.kind))) {
19521964
writer.writeLiteral(text);
19531965
}
1966+
// For version below ES6, emit binary integer literal and octal integer literal in canonical form
1967+
else if (compilerOptions.target < ScriptTarget.ES6 && node.kind === SyntaxKind.NumericLiteral && isBinaryOrOctalIntegerLiteral(text)) {
1968+
write(node.text);
1969+
}
19541970
else {
19551971
write(text);
19561972
}

src/compiler/parser.ts

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -875,25 +875,6 @@ module ts {
875875
return SyntaxKind.FirstTriviaToken <= token && token <= SyntaxKind.LastTriviaToken;
876876
}
877877

878-
export function isUnterminatedTemplateEnd(node: LiteralExpression) {
879-
Debug.assert(isTemplateLiteralKind(node.kind));
880-
var sourceText = getSourceFileOfNode(node).text;
881-
882-
// If we're not at the EOF, we know we must be terminated.
883-
if (node.end !== sourceText.length) {
884-
return false;
885-
}
886-
887-
// The literal can only be unterminated if it is a template tail or a no-sub template.
888-
if (node.kind !== SyntaxKind.TemplateTail && node.kind !== SyntaxKind.NoSubstitutionTemplateLiteral) {
889-
return false;
890-
}
891-
892-
// If we didn't end in a backtick, we must still be in the middle of a template.
893-
// If we did, make sure that it's not the *initial* backtick.
894-
return sourceText.charCodeAt(node.end - 1) !== CharacterCodes.backtick || node.text.length === 0;
895-
}
896-
897878
export function isModifier(token: SyntaxKind): boolean {
898879
switch (token) {
899880
case SyntaxKind.PublicKeyword:
@@ -1734,6 +1715,10 @@ module ts {
17341715
var text = scanner.getTokenValue();
17351716
node.text = internName ? internIdentifier(text) : text;
17361717

1718+
if (scanner.isUnterminated()) {
1719+
node.isUnterminated = true;
1720+
}
1721+
17371722
var tokenPos = scanner.getTokenPos();
17381723
nextToken();
17391724
finishNode(node);
@@ -5513,7 +5498,7 @@ module ts {
55135498

55145499
forEach(rootNames, name => processRootFile(name, false));
55155500
if (!seenNoDefaultLib) {
5516-
processRootFile(host.getDefaultLibFilename(), true);
5501+
processRootFile(host.getDefaultLibFilename(options), true);
55175502
}
55185503
verifyCompilerOptions();
55195504
errors.sort(compareDiagnostics);
@@ -5557,7 +5542,7 @@ module ts {
55575542
}
55585543
var diagnostic: DiagnosticMessage;
55595544
if (hasExtension(filename)) {
5560-
if (!fileExtensionIs(filename, ".ts")) {
5545+
if (!options.allowNonTsExtensions && !fileExtensionIs(filename, ".ts")) {
55615546
diagnostic = Diagnostics.File_0_must_have_extension_ts_or_d_ts;
55625547
}
55635548
else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) {

0 commit comments

Comments
 (0)