Merge branch 'master' into arrowLookAhead

This commit is contained in:
Daniel Rosenwasser
2014-07-24 18:17:30 -07:00
93 changed files with 867 additions and 985 deletions

View File

@@ -4038,7 +4038,7 @@ module ts {
function checkAndAggregateReturnExpressionTypes(body: Block, contextualType?: Type, contextualMapper?: TypeMapper): Type[] {
var aggregatedTypes: Type[] = [];
forEachReturnStatement(body, (returnStatement) => {
forEachReturnStatement(body, returnStatement => {
var expr = returnStatement.expression;
if (expr) {
var type = checkAndMarkExpression(expr, contextualType, contextualMapper);
@@ -4052,7 +4052,7 @@ module ts {
}
function bodyContainsAReturnStatement(funcBody: Block) {
return forEachReturnStatement(funcBody, (returnStatement) => {
return forEachReturnStatement(funcBody, returnStatement => {
return true;
});
}
@@ -5284,7 +5284,7 @@ module ts {
function checkWithStatement(node: WithStatement) {
checkExpression(node.expression);
checkSourceElement(node.statement);
error(node.expression, Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any);
}
function checkSwitchStatement(node: SwitchStatement) {
@@ -5343,7 +5343,7 @@ module ts {
// for interfaces property and indexer might be inherited from different bases
// check if any base class already has both property and indexer.
// check should be performed only if 'type' is the first type that brings property\indexer together
var someBaseClassHasBothPropertyAndIndexer = forEach((<InterfaceType>type).baseTypes, (base) => getPropertyOfType(base, prop.name) && getIndexTypeOfType(base, indexKind));
var someBaseClassHasBothPropertyAndIndexer = forEach((<InterfaceType>type).baseTypes, base => getPropertyOfType(base, prop.name) && getIndexTypeOfType(base, indexKind));
errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : type.symbol.declarations[0];
}

View File

@@ -123,6 +123,7 @@ module ts {
Setters_cannot_return_a_value: { code: 2122, category: DiagnosticCategory.Error, key: "Setters cannot return a value." },
Invalid_left_hand_side_of_assignment_expression: { code: 2130, category: DiagnosticCategory.Error, key: "Invalid left-hand side of assignment expression." },
Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2134, category: DiagnosticCategory.Error, key: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." },
All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2135, category: DiagnosticCategory.Error, key: "All symbols within a 'with' block will be resolved to 'any'." },
The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2139, category: DiagnosticCategory.Error, key: "The operand of an increment or decrement operator must be a variable, property or indexer." },
Overload_signatures_must_all_be_public_or_private: { code: 2150, category: DiagnosticCategory.Error, key: "Overload signatures must all be public or private." },
Overload_signatures_must_all_be_exported_or_not_exported: { code: 2151, category: DiagnosticCategory.Error, key: "Overload signatures must all be exported or not exported." },

View File

@@ -485,6 +485,10 @@
"category": "Error",
"code": 2134
},
"All symbols within a 'with' block will be resolved to 'any'.": {
"category": "Error",
"code": 2135
},
"The operand of an increment or decrement operator must be a variable, property or indexer.": {
"category": "Error",
"code": 2139

View File

@@ -865,12 +865,13 @@ module ts {
return createMissingList<T>();
}
function parseEntityName(): EntityName {
// The allowReservedWords parameter controls whether reserved words are permitted after the first dot
function parseEntityName(allowReservedWords: boolean): EntityName {
var entity: EntityName = parseIdentifier();
while (parseOptional(SyntaxKind.DotToken)) {
var node = <QualifiedName>createNode(SyntaxKind.QualifiedName, entity.pos);
node.left = entity;
node.right = parseIdentifier();
node.right = allowReservedWords ? parseIdentifierName() : parseIdentifier();
entity = finishNode(node);
}
return entity;
@@ -899,7 +900,7 @@ module ts {
function parseTypeReference(): TypeReferenceNode {
var node = <TypeReferenceNode>createNode(SyntaxKind.TypeReference);
node.typeName = parseEntityName();
node.typeName = parseEntityName(/*allowReservedWords*/ false);
if (!scanner.hasPrecedingLineBreak() && token === SyntaxKind.LessThanToken) {
node.typeArguments = parseTypeArguments();
}
@@ -909,7 +910,7 @@ module ts {
function parseTypeQuery(): TypeQueryNode {
var node = <TypeQueryNode>createNode(SyntaxKind.TypeQuery);
parseExpected(SyntaxKind.TypeOfKeyword);
node.exprName = parseEntityName();
node.exprName = parseEntityName(/*allowReservedWords*/ true);
return finishNode(node);
}
@@ -1873,7 +1874,12 @@ module ts {
if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) {
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
var body = parseBody(/* ignoreMissingOpenBrace */ false);
node.initializer = makeFunctionExpression(SyntaxKind.FunctionExpression, node.pos, node.name, sig, body);
// do not propagate property name as name for function expression
// for scenarios like
// var x = 1;
// var y = { x() { } }
// otherwise this will bring y.x into the scope of x which is incorrect
node.initializer = makeFunctionExpression(SyntaxKind.FunctionExpression, node.pos, undefined, sig, body);
}
else {
parseExpected(SyntaxKind.ColonToken);
@@ -2852,7 +2858,7 @@ module ts {
parseExpected(SyntaxKind.ImportKeyword);
node.name = parseIdentifier();
parseExpected(SyntaxKind.EqualsToken);
var entityName = parseEntityName();
var entityName = parseEntityName(/*allowReservedWords*/ false);
if (entityName.kind === SyntaxKind.Identifier && (<Identifier>entityName).text === "require" && parseOptional(SyntaxKind.OpenParenToken)) {
node.externalModuleName = parseStringLiteral();
parseExpected(SyntaxKind.CloseParenToken);

View File

@@ -18,7 +18,7 @@
/// <reference path='..\compiler\sys.ts' />
/// <reference path='external\mocha.d.ts'/>
/// <reference path='external\chai.d.ts'/>
///<reference path='sourceMapRecorder.ts'/>
/// <reference path='sourceMapRecorder.ts'/>
// this will work in the browser via browserify
var _chai: typeof chai = require('chai');
@@ -598,7 +598,7 @@ module Harness {
this.inputFiles.push(file);
}
public compile(options?: ts.CompilerOptions) {
public setCompilerOptions(options?: ts.CompilerOptions) {
this.compileOptions = options || { noResolve: false };
}
@@ -624,7 +624,7 @@ module Harness {
settingsCallback(null);
}
this.settings.forEach(setting => {
this.settings.forEach(setting => {
switch (setting.flag.toLowerCase()) {
// "filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outDir", "noimplicitany", "noresolve"
case "module":
@@ -692,6 +692,10 @@ module Harness {
case 'declaration':
options.declaration = !!setting.value;
break;
case 'newline':
case 'newlines':
sys.newLine = setting.value;
break;
case 'mapsourcefiles':
case 'maproot':
@@ -753,6 +757,9 @@ module Harness {
// Covert the source Map data into the baseline
result.updateSourceMapRecord(program, sourceMapData);
onComplete(result);
// reset what newline means in case the last test changed it
sys.newLine = '\r\n';
return options;
}
}
@@ -891,7 +898,7 @@ module Harness {
var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
// List of allowed metadata names
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outDir", "noimplicitany", "noresolve"];
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outDir", "noimplicitany", "noresolve", "newline", "newlines"];
function extractCompilerSettings(content: string): CompilerSetting[] {
@@ -1119,7 +1126,7 @@ module Harness {
return filePath.indexOf('lib.d.ts') >= 0 || filePath.indexOf('lib.core.d.ts') >= 0;
}
if (Error) (<any>Error).stackTraceLimit = 100;
if (Error) (<any>Error).stackTraceLimit = 1;
}
// TODO: not sure why Utils.evalFile isn't working with this, eventually will concat it like old compiler instead of eval

View File

@@ -104,4 +104,6 @@ if (runners.length === 0) {
// runners.push(new GeneratedFourslashRunner());
}
sys.newLine = '\r\n';
runTests(runners);

View File

@@ -143,7 +143,7 @@ module RWC {
harnessCompiler.addInputFile({ unitName: resolvedPath, content: content });
});
harnessCompiler.compile();
harnessCompiler.setCompilerOptions();
// Emit the results
harnessCompiler.emitAll(emitterIOHost);

View File

@@ -37,7 +37,7 @@ class UnitTestRunner extends RunnerBase {
return { unitName: test, content: Harness.IO.readFile(test) }
});
harnessCompiler.addInputFiles(toBeAdded);
harnessCompiler.compile({ noResolve: true });
harnessCompiler.setCompilerOptions({ noResolve: true });
var stdout = new Harness.Compiler.EmitterIOHost();
var emitDiagnostics = harnessCompiler.emitAll(stdout);