Merge branch 'master' into argumentTypeErrors
This commit is contained in:
commit
f991054691
16
.travis.yml
16
.travis.yml
|
@ -1,3 +1,13 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- '0.10'
|
||||
|
||||
before_script: npm install -g codeclimate-test-reporter
|
||||
|
||||
after_script:
|
||||
- cat coverage/lcov.info | codeclimate
|
||||
|
||||
addons:
|
||||
code_climate:
|
||||
repo_token: 9852ac5362c8cc38c07ca5adc0f94c20c6c79bd78e17933dc284598a65338656
|
||||
|
|
7
Jakefile
7
Jakefile
|
@ -367,6 +367,13 @@ task("runtests", ["tests", builtLocalDirectory], function() {
|
|||
exec(cmd, deleteTemporaryProjectOutput);
|
||||
}, {async: true});
|
||||
|
||||
desc("Generates code coverage data via instanbul")
|
||||
task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
|
||||
var cmd = "istanbul cover node_modules/mocha/bin/_mocha -- -R dot " + run;
|
||||
console.log(cmd);
|
||||
exec(cmd);
|
||||
}, { async: true });
|
||||
|
||||
// Browser tests
|
||||
var nodeServerOutFile = 'tests/webTestServer.js'
|
||||
var nodeServerInFile = 'tests/webTestServer.ts'
|
||||
|
|
|
@ -36,9 +36,11 @@
|
|||
"jake" : "latest",
|
||||
"mocha" : "latest",
|
||||
"chai" : "latest",
|
||||
"browserify" : "latest"
|
||||
"browserify" : "latest",
|
||||
"istanbul": "latest",
|
||||
"codeclimate-test-reporter": "latest"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jake runtests"
|
||||
"test": "jake generate-code-coverage"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5288,9 +5288,6 @@ module ts {
|
|||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
error(node, Diagnostics.return_statement_has_no_containing_function);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ module ts {
|
|||
[index: string]: T;
|
||||
}
|
||||
|
||||
export interface StringSet extends Map<any> { }
|
||||
|
||||
export function forEach<T, U>(array: T[], callback: (element: T) => U): U {
|
||||
var result: U;
|
||||
if (array) {
|
||||
|
|
|
@ -89,16 +89,21 @@ module ts {
|
|||
with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in strict mode." },
|
||||
delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: DiagnosticCategory.Error, key: "'delete' cannot be called on an identifier in strict mode." },
|
||||
Invalid_left_hand_side_in_for_in_statement: { code: 1103, category: DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...in' statement." },
|
||||
continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: DiagnosticCategory.Error, key: "'continue' statement can only be used within an enclosing iteration statement." },
|
||||
break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: DiagnosticCategory.Error, key: "'break' statement can only be used within an enclosing iteration or switch statement." },
|
||||
Jump_target_not_found: { code: 1106, category: DiagnosticCategory.Error, key: "Jump target not found." },
|
||||
A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: DiagnosticCategory.Error, key: "A 'continue' statement can only be used within an enclosing iteration statement." },
|
||||
A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: DiagnosticCategory.Error, key: "A 'break' statement can only be used within an enclosing iteration or switch statement." },
|
||||
Jump_target_cannot_cross_function_boundary: { code: 1107, category: DiagnosticCategory.Error, key: "Jump target cannot cross function boundary." },
|
||||
return_statement_must_be_contained_within_a_function_body: { code: 1108, category: DiagnosticCategory.Error, key: "'return' statement must be contained within a function body." },
|
||||
A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: DiagnosticCategory.Error, key: "A 'return' statement can only be used within a function body." },
|
||||
Expression_expected: { code: -9999999, category: DiagnosticCategory.Error, key: "Expression expected." },
|
||||
Type_expected: { code: -9999999, category: DiagnosticCategory.Error, key: "Type expected." },
|
||||
A_constructor_implementation_cannot_be_declared_in_an_ambient_context: { code: 1111, category: DiagnosticCategory.Error, key: "A constructor implementation cannot be declared in an ambient context." },
|
||||
A_class_member_cannot_be_declared_optional: { code: 1112, category: DiagnosticCategory.Error, key: "A class member cannot be declared optional." },
|
||||
A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement." },
|
||||
Duplicate_label_0: { code: 1114, category: DiagnosticCategory.Error, key: "Duplicate label '{0}'" },
|
||||
A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: DiagnosticCategory.Error, key: "A 'continue' statement can only jump to a label of an enclosing iteration statement." },
|
||||
A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: DiagnosticCategory.Error, key: "A 'break' statement can only jump to a label of an enclosing statement." },
|
||||
An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: DiagnosticCategory.Error, key: "An object literal cannot have multiple properties with the same name in strict mode." },
|
||||
An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: DiagnosticCategory.Error, key: "An object literal cannot have multiple get/set accessors with the same name." },
|
||||
An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: DiagnosticCategory.Error, key: "An object literal cannot have property and accessor with the same name." },
|
||||
Duplicate_identifier_0: { code: 2000, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
|
||||
new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 2068, category: DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead." },
|
||||
Multiple_constructor_implementations_are_not_allowed: { code: 2070, category: DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." },
|
||||
|
@ -270,7 +275,6 @@ module ts {
|
|||
Unknown_identifier_0: { code: -9999999, category: DiagnosticCategory.Error, key: "Unknown identifier '{0}'." },
|
||||
Property_0_is_inaccessible: { code: -9999999, category: DiagnosticCategory.Error, key: "Property '{0}' is inaccessible." },
|
||||
Function_implementation_expected: { code: -9999999, category: DiagnosticCategory.Error, key: "Function implementation expected." },
|
||||
return_statement_has_no_containing_function: { code: -9999999, category: DiagnosticCategory.Error, key: "'return' statement has no containing function." },
|
||||
Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: -9999999, category: DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." },
|
||||
Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: -9999999, category: DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." },
|
||||
Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: -9999999, category: DiagnosticCategory.Error, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." },
|
||||
|
|
|
@ -348,23 +348,19 @@
|
|||
"category": "Error",
|
||||
"code": 1103
|
||||
},
|
||||
"'continue' statement can only be used within an enclosing iteration statement.": {
|
||||
"A 'continue' statement can only be used within an enclosing iteration statement.": {
|
||||
"category": "Error",
|
||||
"code": 1104
|
||||
},
|
||||
"'break' statement can only be used within an enclosing iteration or switch statement.": {
|
||||
"A 'break' statement can only be used within an enclosing iteration or switch statement.": {
|
||||
"category": "Error",
|
||||
"code": 1105
|
||||
},
|
||||
"Jump target not found.": {
|
||||
"category": "Error",
|
||||
"code": 1106
|
||||
},
|
||||
"Jump target cannot cross function boundary.": {
|
||||
"category": "Error",
|
||||
"code": 1107
|
||||
},
|
||||
"'return' statement must be contained within a function body.": {
|
||||
"A 'return' statement can only be used within a function body.": {
|
||||
"category": "Error",
|
||||
"code": 1108
|
||||
},
|
||||
|
@ -388,7 +384,30 @@
|
|||
"category": "Error",
|
||||
"code": 1113
|
||||
},
|
||||
|
||||
"Duplicate label '{0}'": {
|
||||
"category": "Error",
|
||||
"code": 1114
|
||||
},
|
||||
"A 'continue' statement can only jump to a label of an enclosing iteration statement.": {
|
||||
"category": "Error",
|
||||
"code": 1115
|
||||
},
|
||||
"A 'break' statement can only jump to a label of an enclosing statement.": {
|
||||
"category": "Error",
|
||||
"code": 1116
|
||||
},
|
||||
"An object literal cannot have multiple properties with the same name in strict mode.": {
|
||||
"category": "Error",
|
||||
"code": 1117
|
||||
},
|
||||
"An object literal cannot have multiple get/set accessors with the same name.": {
|
||||
"category": "Error",
|
||||
"code": 1118
|
||||
},
|
||||
"An object literal cannot have property and accessor with the same name.": {
|
||||
"category": "Error",
|
||||
"code": 1119
|
||||
},
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2000
|
||||
|
@ -1098,10 +1117,6 @@
|
|||
"category": "Error",
|
||||
"code": -9999999
|
||||
},
|
||||
"'return' statement has no containing function.": {
|
||||
"category": "Error",
|
||||
"code": -9999999
|
||||
},
|
||||
"Property '{0}' of type '{1}' is not assignable to string index type '{2}'.": {
|
||||
"category": "Error",
|
||||
"code": -9999999
|
||||
|
|
|
@ -1669,8 +1669,7 @@ module ts {
|
|||
|
||||
function emitDirectivePrologues(statements: Statement[], startWithNewLine: boolean): number {
|
||||
for (var i = 0; i < statements.length; ++i) {
|
||||
if (statements[i].kind === SyntaxKind.ExpressionStatement &&
|
||||
(<ExpressionStatement>statements[i]).expression.kind === SyntaxKind.StringLiteral) {
|
||||
if (isPrologueDirective(statements[i])) {
|
||||
if (startWithNewLine || i > 0) {
|
||||
writeLine();
|
||||
}
|
||||
|
|
|
@ -55,6 +55,10 @@ module ts {
|
|||
return skipTrivia(getSourceFileOfNode(node).text, node.pos);
|
||||
}
|
||||
|
||||
export function getSourceTextOfNodeFromSourceText(sourceText: string, node: Node): string {
|
||||
return sourceText.substring(skipTrivia(sourceText, node.pos), node.end);
|
||||
}
|
||||
|
||||
export function getSourceTextOfNode(node: Node): string {
|
||||
var text = getSourceFileOfNode(node).text;
|
||||
return text.substring(skipTrivia(text, node.pos), node.end);
|
||||
|
@ -119,6 +123,22 @@ module ts {
|
|||
return file.externalModuleIndicator !== undefined;
|
||||
}
|
||||
|
||||
export function isPrologueDirective(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.ExpressionStatement && (<ExpressionStatement>node).expression.kind === SyntaxKind.StringLiteral;
|
||||
}
|
||||
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.Identifier &&
|
||||
(<Identifier>node).text &&
|
||||
((<Identifier>node).text === "eval" || (<Identifier>node).text === "arguments")
|
||||
}
|
||||
|
||||
/// Should be called only on prologue directives (isPrologueDirective(node) should be true)
|
||||
function isUseStrictPrologueDirective(node: Node): boolean {
|
||||
Debug.assert(isPrologueDirective(node));
|
||||
return (<Identifier>(<ExpressionStatement>node).expression).text === "use strict";
|
||||
}
|
||||
|
||||
// Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes
|
||||
// stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise,
|
||||
// embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns
|
||||
|
@ -373,6 +393,22 @@ module ts {
|
|||
Preserve
|
||||
}
|
||||
|
||||
// Tracks whether we nested (directly or indirectly) in a certain control block.
|
||||
// Used for validating break and continue statements.
|
||||
enum ControlBlockContext {
|
||||
NotNested,
|
||||
Nested,
|
||||
CrossingFunctionBoundary
|
||||
}
|
||||
|
||||
interface LabelledStatementInfo {
|
||||
addLabel(label: Identifier): void;
|
||||
pushCurrentLabelSet(isIterationStatement: boolean): void;
|
||||
pushFunctionBoundary(): void;
|
||||
pop(): void;
|
||||
nodeIsNestedInLabel(label: Identifier, requireIterationStatement: boolean, stopAtFunctionBoundary: boolean): ControlBlockContext;
|
||||
}
|
||||
|
||||
export function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget): SourceFile {
|
||||
var file: SourceFile;
|
||||
var scanner: Scanner;
|
||||
|
@ -383,9 +419,117 @@ module ts {
|
|||
var identifierCount = 0;
|
||||
var nodeCount = 0;
|
||||
var lineStarts: number[];
|
||||
var isInStrictMode = false;
|
||||
|
||||
var lookAheadMode = LookAheadMode.NotLookingAhead;
|
||||
var inAmbientContext = false;
|
||||
var inFunctionBody = false;
|
||||
var inSwitchStatement = ControlBlockContext.NotNested;
|
||||
var inIterationStatement = ControlBlockContext.NotNested;
|
||||
|
||||
// The following is a state machine that tracks what labels are in our current parsing
|
||||
// context. So if we are parsing a node that is nested (arbitrarily deeply) in a label,
|
||||
// it will be tracked in this data structure. It is used for checking break/continue
|
||||
// statements, and checking for duplicate labels.
|
||||
var labelledStatementInfo: LabelledStatementInfo = (() => {
|
||||
// These are initialized on demand because labels are rare, so it is usually
|
||||
// not even necessary to allocate these.
|
||||
var functionBoundarySentinel: StringSet;
|
||||
var currentLabelSet: StringSet;
|
||||
var labelSetStack: StringSet[];
|
||||
var isIterationStack: boolean[];
|
||||
|
||||
function addLabel(label: Identifier): void {
|
||||
if (!currentLabelSet) {
|
||||
currentLabelSet = {};
|
||||
}
|
||||
currentLabelSet[label.text] = true;
|
||||
}
|
||||
|
||||
function pushCurrentLabelSet(isIterationStatement: boolean): void {
|
||||
if (!labelSetStack && !isIterationStack) {
|
||||
labelSetStack = [];
|
||||
isIterationStack = [];
|
||||
}
|
||||
Debug.assert(currentLabelSet !== undefined);
|
||||
labelSetStack.push(currentLabelSet);
|
||||
isIterationStack.push(isIterationStatement);
|
||||
currentLabelSet = undefined;
|
||||
}
|
||||
|
||||
function pushFunctionBoundary(): void {
|
||||
if (!functionBoundarySentinel) {
|
||||
functionBoundarySentinel = {};
|
||||
if (!labelSetStack && !isIterationStack) {
|
||||
labelSetStack = [];
|
||||
isIterationStack = [];
|
||||
}
|
||||
}
|
||||
Debug.assert(currentLabelSet === undefined);
|
||||
labelSetStack.push(functionBoundarySentinel);
|
||||
|
||||
// It does not matter what we push here, since we will never ask if a function boundary
|
||||
// is an iteration statement
|
||||
isIterationStack.push(false);
|
||||
}
|
||||
|
||||
function pop(): void {
|
||||
// Assert that we are in a "pushed" state
|
||||
Debug.assert(labelSetStack.length && isIterationStack.length && currentLabelSet === undefined);
|
||||
labelSetStack.pop();
|
||||
isIterationStack.pop();
|
||||
}
|
||||
|
||||
function nodeIsNestedInLabel(label: Identifier, requireIterationStatement: boolean, stopAtFunctionBoundary: boolean): ControlBlockContext {
|
||||
if (!requireIterationStatement && currentLabelSet && hasProperty(currentLabelSet, label.text)) {
|
||||
return ControlBlockContext.Nested;
|
||||
}
|
||||
|
||||
if (!labelSetStack) {
|
||||
return ControlBlockContext.NotNested;
|
||||
}
|
||||
|
||||
// We want to start searching for the label at the lowest point in the tree,
|
||||
// and climb up from there. So we start at the end of the labelSetStack array.
|
||||
var crossedFunctionBoundary = false;
|
||||
for (var i = labelSetStack.length - 1; i >= 0; i--) {
|
||||
var labelSet = labelSetStack[i];
|
||||
// Not allowed to cross function boundaries, so stop if we encounter one
|
||||
if (labelSet === functionBoundarySentinel) {
|
||||
if (stopAtFunctionBoundary) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
crossedFunctionBoundary = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// If we require an iteration statement, only search in the current
|
||||
// statement if it is an iteration statement
|
||||
if (requireIterationStatement && isIterationStack[i] === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hasProperty(labelSet, label.text)) {
|
||||
return crossedFunctionBoundary ? ControlBlockContext.CrossingFunctionBoundary : ControlBlockContext.Nested;
|
||||
}
|
||||
}
|
||||
|
||||
// This is a bit of a misnomer. If the caller passed true for stopAtFunctionBoundary,
|
||||
// there actually may be an enclosing label across a function boundary, but we will
|
||||
// just return NotNested
|
||||
return ControlBlockContext.NotNested;
|
||||
}
|
||||
|
||||
return {
|
||||
addLabel: addLabel,
|
||||
pushCurrentLabelSet: pushCurrentLabelSet,
|
||||
pushFunctionBoundary: pushFunctionBoundary,
|
||||
pop: pop,
|
||||
nodeIsNestedInLabel: nodeIsNestedInLabel,
|
||||
};
|
||||
})();
|
||||
|
||||
function getLineAndCharacterlFromSourcePosition(position: number) {
|
||||
if (!lineStarts) {
|
||||
|
@ -418,6 +562,13 @@ module ts {
|
|||
file.syntacticErrors.push(createFileDiagnostic(file, start, length, message, arg0, arg1, arg2));
|
||||
}
|
||||
|
||||
function reportInvalidUseInStrictMode(node: Identifier): void {
|
||||
// identifierToString cannot be used here since it uses backreference to 'parent' that is not yet set
|
||||
var name = sourceText.substring(skipTrivia(sourceText, node.pos), node.end);
|
||||
grammarErrorOnNode(node, Diagnostics.Invalid_use_of_0_in_strict_mode, name);
|
||||
}
|
||||
|
||||
|
||||
function grammarErrorAtPos(start: number, length: number, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void {
|
||||
file.syntacticErrors.push(createFileDiagnostic(file, start, length, message, arg0, arg1, arg2));
|
||||
}
|
||||
|
@ -522,7 +673,7 @@ module ts {
|
|||
}
|
||||
|
||||
function isIdentifier(): boolean {
|
||||
return token === SyntaxKind.Identifier || token > SyntaxKind.LastReservedWord;
|
||||
return token === SyntaxKind.Identifier || (isInStrictMode ? token > SyntaxKind.LastFutureReservedWord : token > SyntaxKind.LastReservedWord);
|
||||
}
|
||||
|
||||
function isSemicolon(): boolean {
|
||||
|
@ -767,14 +918,28 @@ module ts {
|
|||
}
|
||||
|
||||
// Parses a list of elements
|
||||
function parseList<T extends Node>(kind: ParsingContext, parseElement: () => T): NodeArray<T> {
|
||||
function parseList<T extends Node>(kind: ParsingContext, checkForStrictMode: boolean, parseElement: () => T): NodeArray<T> {
|
||||
var saveParsingContext = parsingContext;
|
||||
parsingContext |= 1 << kind;
|
||||
var result = <NodeArray<T>>[];
|
||||
result.pos = getNodePos();
|
||||
var saveIsInStrictMode = isInStrictMode;
|
||||
while (!isListTerminator(kind)) {
|
||||
if (isListElement(kind, /* inErrorRecovery */ false)) {
|
||||
result.push(parseElement());
|
||||
var element = parseElement();
|
||||
result.push(element);
|
||||
// test elements only if we are not already in strict mode
|
||||
if (!isInStrictMode && checkForStrictMode) {
|
||||
if (isPrologueDirective(element)) {
|
||||
if (isUseStrictPrologueDirective(element)) {
|
||||
isInStrictMode = true;
|
||||
checkForStrictMode = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
checkForStrictMode = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
error(parsingContextErrors(kind));
|
||||
|
@ -784,6 +949,7 @@ module ts {
|
|||
nextToken();
|
||||
}
|
||||
}
|
||||
isInStrictMode = saveIsInStrictMode;
|
||||
result.end = getNodeEnd();
|
||||
parsingContext = saveParsingContext;
|
||||
return result;
|
||||
|
@ -969,6 +1135,18 @@ module ts {
|
|||
node.flags |= NodeFlags.Rest;
|
||||
}
|
||||
node.name = parseIdentifier();
|
||||
if (node.name.kind === SyntaxKind.Missing && node.flags === 0 && isModifier(token)) {
|
||||
// in cases like
|
||||
// 'use strict'
|
||||
// function foo(static)
|
||||
// isParameter('static') === true, because of isModifier('static')
|
||||
// however 'static' is not a legal identifier in a strict mode.
|
||||
// so result of this function will be ParameterDeclaration (flags = 0, name = missing, type = undefined, initializer = undefined)
|
||||
// and current token will not change => parsing of the enclosing parameter list will last till the end of time (or OOM)
|
||||
// to avoid this we'll advance cursor to the next token.
|
||||
nextToken();
|
||||
}
|
||||
|
||||
if (parseOptional(SyntaxKind.QuestionToken)) {
|
||||
node.flags |= NodeFlags.QuestionMark;
|
||||
}
|
||||
|
@ -1013,8 +1191,16 @@ module ts {
|
|||
|
||||
for (var i = 0; i < parameterCount; i++) {
|
||||
var parameter = parameters[i];
|
||||
|
||||
if (parameter.flags & NodeFlags.Rest) {
|
||||
// It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the
|
||||
// Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code
|
||||
// or if its FunctionBody is strict code(11.1.5).
|
||||
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
|
||||
// strict mode FunctionDeclaration or FunctionExpression(13.1)
|
||||
if (isInStrictMode && isEvalOrArgumentsIdentifier(parameter.name)) {
|
||||
reportInvalidUseInStrictMode(parameter.name);
|
||||
return;
|
||||
}
|
||||
else if (parameter.flags & NodeFlags.Rest) {
|
||||
if (i !== (parameterCount - 1)) {
|
||||
grammarErrorOnNode(parameter.name, Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
|
||||
return;
|
||||
|
@ -1171,7 +1357,7 @@ module ts {
|
|||
function parseTypeLiteral(): TypeLiteralNode {
|
||||
var node = <TypeLiteralNode>createNode(SyntaxKind.TypeLiteral);
|
||||
if (parseExpected(SyntaxKind.OpenBraceToken)) {
|
||||
node.members = parseList(ParsingContext.TypeMembers, parseTypeMember);
|
||||
node.members = parseList(ParsingContext.TypeMembers, /*checkForStrictMode*/ false, parseTypeMember);
|
||||
parseExpected(SyntaxKind.CloseBraceToken);
|
||||
}
|
||||
else {
|
||||
|
@ -1359,8 +1545,13 @@ module ts {
|
|||
|
||||
// Now see if we might be in cases '2' or '3'.
|
||||
// If the expression was a LHS expression, and we have an assignment operator, then
|
||||
// we're in '2' or '3'. Consume the assignement and return.
|
||||
// we're in '2' or '3'. Consume the assignment and return.
|
||||
if (isLeftHandSideExpression(expr) && isAssignmentOperator()) {
|
||||
if (isInStrictMode && isEvalOrArgumentsIdentifier(expr)) {
|
||||
// ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an
|
||||
// Assignment operator(11.13) or of a PostfixExpression(11.3)
|
||||
reportInvalidUseInStrictMode(<Identifier>expr);
|
||||
}
|
||||
var operator = token;
|
||||
nextToken();
|
||||
return makeBinaryExpression(expr, operator, parseAssignmentExpression(noIn));
|
||||
|
@ -1446,64 +1637,87 @@ module ts {
|
|||
function tryParseParenthesizedArrowFunctionExpression(): Expression {
|
||||
var pos = getNodePos();
|
||||
|
||||
// Indicates whether we are certain that we should parse an arrow expression.
|
||||
var triState = isParenthesizedArrowFunctionExpression();
|
||||
|
||||
// It is not a parenthesized arrow function.
|
||||
if (triState === Tristate.False) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// If we're certain that we have an arrow function expression, then just parse one out.
|
||||
if (triState === Tristate.True) {
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
||||
|
||||
// If we have an arrow, then try to parse the body.
|
||||
if (parseExpected(SyntaxKind.EqualsGreaterThanToken)) {
|
||||
return parseArrowExpressionTail(pos, sig, /*noIn:*/ false);
|
||||
// Even if not, try to parse if we have an opening brace, just in case we're in an error state.
|
||||
if (parseExpected(SyntaxKind.EqualsGreaterThanToken) || token === SyntaxKind.OpenBraceToken) {
|
||||
return parseArrowExpressionTail(pos, sig, /* noIn: */ false);
|
||||
}
|
||||
// If not, we're probably better off bailing out and returning a bogus function expression.
|
||||
else {
|
||||
// If not, we're probably better off bailing out and returning a bogus function expression.
|
||||
return makeFunctionExpression(SyntaxKind.ArrowFunction, pos, /* name */ undefined, sig, createMissingNode());
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, *maybe* we had an arrow function and we need to *try* to parse it out
|
||||
// (which will ensure we rollback if we fail).
|
||||
var sig = tryParse(parseSignatureAndArrow);
|
||||
if (sig === undefined) {
|
||||
return undefined;
|
||||
// *Maybe* we had an arrow function and we need to try to parse it out,
|
||||
// rolling back and trying other parses if we fail.
|
||||
var sig = tryParseSignatureIfArrowOrBraceFollows();
|
||||
if (sig) {
|
||||
parseExpected(SyntaxKind.EqualsGreaterThanToken);
|
||||
return parseArrowExpressionTail(pos, sig, /*noIn:*/ false);
|
||||
}
|
||||
else {
|
||||
return parseArrowExpressionTail(pos, sig, /*noIn:*/ false);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// True -> There is definitely a parenthesized arrow function here.
|
||||
// False -> There is definitely *not* a parenthesized arrow function here.
|
||||
// True -> We definitely expect a parenthesized arrow function here.
|
||||
// False -> There *cannot* be a parenthesized arrow function here.
|
||||
// Unknown -> There *might* be a parenthesized arrow function here.
|
||||
// Speculatively look ahead to be sure.
|
||||
// Speculatively look ahead to be sure, and rollback if not.
|
||||
function isParenthesizedArrowFunctionExpression(): Tristate {
|
||||
if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) {
|
||||
return lookAhead(() => {
|
||||
var first = token;
|
||||
nextToken();
|
||||
var second = nextToken();
|
||||
|
||||
if (first === SyntaxKind.OpenParenToken) {
|
||||
if (token === SyntaxKind.CloseParenToken || token === SyntaxKind.DotDotDotToken) {
|
||||
// Simple cases. if we see () or (... then presume that presume
|
||||
// that this must be an arrow function. Note, this may be too aggressive
|
||||
// for the "()" case. It's not uncommon for this to appear while editing
|
||||
// code. We should look to see if there's actually a => before proceeding.
|
||||
if (second === SyntaxKind.CloseParenToken) {
|
||||
// Simple cases: "() =>", "(): ", and "() {".
|
||||
// This is an arrow function with no parameters.
|
||||
// The last one is not actually an arrow function,
|
||||
// but this is probably what the user intended.
|
||||
var third = nextToken();
|
||||
switch (third) {
|
||||
case SyntaxKind.EqualsGreaterThanToken:
|
||||
case SyntaxKind.ColonToken:
|
||||
case SyntaxKind.OpenBraceToken:
|
||||
return Tristate.True;
|
||||
default:
|
||||
return Tristate.False;
|
||||
}
|
||||
}
|
||||
|
||||
// Simple case: "(..."
|
||||
// This is an arrow function with a rest parameter.
|
||||
if (second === SyntaxKind.DotDotDotToken) {
|
||||
return Tristate.True;
|
||||
}
|
||||
|
||||
// If we had "(" followed by something that's not an identifier,
|
||||
// then this definitely doesn't look like a lambda.
|
||||
// Note: we could be a little more lenient and allow
|
||||
// "(public" or "(private". These would not ever actually be allowed,
|
||||
// but we could provide a good error message instead of bailing out.
|
||||
if (!isIdentifier()) {
|
||||
// We had "(" not followed by an identifier. This definitely doesn't
|
||||
// look like a lambda. Note: we could be a little more lenient and allow
|
||||
// (public or (private. These would not ever actually be allowed,
|
||||
// but we could provide a good error message instead of bailing out.
|
||||
return Tristate.False;
|
||||
}
|
||||
|
||||
// If we have something like "(a:", then we must have a
|
||||
// type-annotated parameter in an arrow function expression.
|
||||
if (nextToken() === SyntaxKind.ColonToken) {
|
||||
return Tristate.True;
|
||||
}
|
||||
|
||||
// This *could* be a parenthesized arrow function.
|
||||
// Return Unknown to let the caller know.
|
||||
return Tristate.Unknown;
|
||||
|
@ -1527,10 +1741,24 @@ module ts {
|
|||
return Tristate.False;
|
||||
}
|
||||
|
||||
function parseSignatureAndArrow(): ParsedSignature {
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
||||
parseExpected(SyntaxKind.EqualsGreaterThanToken);
|
||||
return sig;
|
||||
function tryParseSignatureIfArrowOrBraceFollows(): ParsedSignature {
|
||||
return tryParse(() => {
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
||||
|
||||
// Parsing a signature isn't enough.
|
||||
// Parenthesized arrow signatures often look like other valid expressions.
|
||||
// For instance:
|
||||
// - "(x = 10)" is an assignment expression parsed as a signature with a default parameter value.
|
||||
// - "(x,y)" is a comma expression parsed as a signature with two parameters.
|
||||
// - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation.
|
||||
//
|
||||
// So we need just a bit of lookahead to ensure that it can only be a signature.
|
||||
if (token === SyntaxKind.EqualsGreaterThanToken || token === SyntaxKind.OpenBraceToken) {
|
||||
return sig;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
|
||||
function parseArrowExpressionTail(pos: number, sig: ParsedSignature, noIn: boolean): FunctionExpression {
|
||||
|
@ -1660,6 +1888,19 @@ module ts {
|
|||
var operator = token;
|
||||
nextToken();
|
||||
var operand = parseUnaryExpression();
|
||||
if (isInStrictMode) {
|
||||
// The identifier eval or arguments may not appear as the LeftHandSideExpression of an
|
||||
// Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression
|
||||
// operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator
|
||||
if ((token === SyntaxKind.PlusPlusToken || token === SyntaxKind.MinusMinusToken) && isEvalOrArgumentsIdentifier(operand)) {
|
||||
reportInvalidUseInStrictMode(<Identifier>operand);
|
||||
}
|
||||
else if (token === SyntaxKind.DeleteKeyword && operand.kind === SyntaxKind.Identifier) {
|
||||
// When a delete operator occurs within strict mode code, a SyntaxError is thrown if its
|
||||
// UnaryExpression is a direct reference to a variable, function argument, or function name
|
||||
grammarErrorOnNode(operand, Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode);
|
||||
}
|
||||
}
|
||||
return makeUnaryExpression(SyntaxKind.PrefixOperator, pos, operator, operand);
|
||||
case SyntaxKind.LessThanToken:
|
||||
return parseTypeAssertion();
|
||||
|
@ -1681,6 +1922,12 @@ module ts {
|
|||
|
||||
Debug.assert(isLeftHandSideExpression(expr));
|
||||
if ((token === SyntaxKind.PlusPlusToken || token === SyntaxKind.MinusMinusToken) && !scanner.hasPrecedingLineBreak()) {
|
||||
// The identifier eval or arguments may not appear as the LeftHandSideExpression of an
|
||||
// Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression
|
||||
// operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator.
|
||||
if (isInStrictMode && isEvalOrArgumentsIdentifier(expr)) {
|
||||
reportInvalidUseInStrictMode(<Identifier>expr);
|
||||
}
|
||||
var operator = token;
|
||||
nextToken();
|
||||
expr = makeUnaryExpression(SyntaxKind.PostfixOperator, expr.pos, operator, expr);
|
||||
|
@ -1867,6 +2114,61 @@ module ts {
|
|||
if (scanner.hasPrecedingLineBreak()) node.flags |= NodeFlags.MultiLine;
|
||||
node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralMember, TrailingCommaBehavior.Preserve);
|
||||
parseExpected(SyntaxKind.CloseBraceToken);
|
||||
|
||||
var seen: Map<SymbolFlags> = {};
|
||||
var Property = 1;
|
||||
var GetAccessor = 2;
|
||||
var SetAccesor = 4;
|
||||
var GetOrSetAccessor = GetAccessor | SetAccesor;
|
||||
forEach(node.properties, (p: Declaration) => {
|
||||
if (p.kind === SyntaxKind.OmittedExpression) {
|
||||
return;
|
||||
}
|
||||
// ECMA-262 11.1.5 Object Initialiser
|
||||
// If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
// a.This production is contained in strict code and IsDataDescriptor(previous) is true and
|
||||
// IsDataDescriptor(propId.descriptor) is true.
|
||||
// b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true.
|
||||
// c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true.
|
||||
// d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true
|
||||
// and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields
|
||||
var currentKind: number;
|
||||
if (p.kind === SyntaxKind.PropertyAssignment) {
|
||||
currentKind = Property;
|
||||
}
|
||||
else if (p.kind === SyntaxKind.GetAccessor) {
|
||||
currentKind = GetAccessor;
|
||||
}
|
||||
else if (p.kind === SyntaxKind.SetAccessor) {
|
||||
currentKind = SetAccesor;
|
||||
}
|
||||
else {
|
||||
Debug.fail("Unexpected syntax kind:" + SyntaxKind[p.kind]);
|
||||
}
|
||||
|
||||
if (!hasProperty(seen, p.name.text)) {
|
||||
seen[p.name.text] = currentKind;
|
||||
}
|
||||
else {
|
||||
var existingKind = seen[p.name.text];
|
||||
if (currentKind === Property && existingKind === Property) {
|
||||
if (isInStrictMode) {
|
||||
grammarErrorOnNode(p.name, Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode);
|
||||
}
|
||||
}
|
||||
else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) {
|
||||
if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) {
|
||||
seen[p.name.text] = currentKind | existingKind;
|
||||
}
|
||||
else {
|
||||
grammarErrorOnNode(p.name, Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
grammarErrorOnNode(p.name, Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name);
|
||||
}
|
||||
}
|
||||
});
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
@ -1876,6 +2178,11 @@ module ts {
|
|||
var name = isIdentifier() ? parseIdentifier() : undefined;
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
||||
var body = parseBody(/* ignoreMissingOpenBrace */ false);
|
||||
if (name && isInStrictMode && isEvalOrArgumentsIdentifier(name)) {
|
||||
// It is a SyntaxError to use within strict mode code the identifiers eval or arguments as the
|
||||
// Identifier of a FunctionDeclaration or FunctionExpression or as a formal parameter name(13.1)
|
||||
reportInvalidUseInStrictMode(name);
|
||||
}
|
||||
return makeFunctionExpression(SyntaxKind.FunctionExpression, pos, name, sig, body);
|
||||
}
|
||||
|
||||
|
@ -1902,10 +2209,10 @@ module ts {
|
|||
|
||||
// STATEMENTS
|
||||
|
||||
function parseBlock(ignoreMissingOpenBrace: boolean): Block {
|
||||
function parseBlock(ignoreMissingOpenBrace: boolean, checkForStrictMode: boolean): Block {
|
||||
var node = <Block>createNode(SyntaxKind.Block);
|
||||
if (parseExpected(SyntaxKind.OpenBraceToken) || ignoreMissingOpenBrace) {
|
||||
node.statements = parseList(ParsingContext.BlockStatements, parseStatement);
|
||||
node.statements = parseList(ParsingContext.BlockStatements,checkForStrictMode, parseStatement);
|
||||
parseExpected(SyntaxKind.CloseBraceToken);
|
||||
}
|
||||
else {
|
||||
|
@ -1915,8 +2222,27 @@ module ts {
|
|||
}
|
||||
|
||||
function parseBody(ignoreMissingOpenBrace: boolean): Block {
|
||||
var block = parseBlock(ignoreMissingOpenBrace);
|
||||
var saveInFunctionBody = inFunctionBody;
|
||||
var saveInSwitchStatement = inSwitchStatement;
|
||||
var saveInIterationStatement = inIterationStatement;
|
||||
|
||||
inFunctionBody = true;
|
||||
if (inSwitchStatement === ControlBlockContext.Nested) {
|
||||
inSwitchStatement = ControlBlockContext.CrossingFunctionBoundary;
|
||||
}
|
||||
if (inIterationStatement === ControlBlockContext.Nested) {
|
||||
inIterationStatement = ControlBlockContext.CrossingFunctionBoundary;
|
||||
}
|
||||
labelledStatementInfo.pushFunctionBoundary();
|
||||
|
||||
var block = parseBlock(ignoreMissingOpenBrace, /*checkForStrictMode*/ true);
|
||||
block.kind = SyntaxKind.FunctionBlock;
|
||||
|
||||
labelledStatementInfo.pop();
|
||||
inFunctionBody = saveInFunctionBody;
|
||||
inSwitchStatement = saveInSwitchStatement;
|
||||
inIterationStatement = saveInIterationStatement;
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
|
@ -1940,7 +2266,12 @@ module ts {
|
|||
function parseDoStatement(): DoStatement {
|
||||
var node = <DoStatement>createNode(SyntaxKind.DoStatement);
|
||||
parseExpected(SyntaxKind.DoKeyword);
|
||||
|
||||
var saveInIterationStatement = inIterationStatement;
|
||||
inIterationStatement = ControlBlockContext.Nested;
|
||||
node.statement = parseStatement();
|
||||
inIterationStatement = saveInIterationStatement;
|
||||
|
||||
parseExpected(SyntaxKind.WhileKeyword);
|
||||
parseExpected(SyntaxKind.OpenParenToken);
|
||||
node.expression = parseExpression();
|
||||
|
@ -1960,7 +2291,12 @@ module ts {
|
|||
parseExpected(SyntaxKind.OpenParenToken);
|
||||
node.expression = parseExpression();
|
||||
parseExpected(SyntaxKind.CloseParenToken);
|
||||
|
||||
var saveInIterationStatement = inIterationStatement;
|
||||
inIterationStatement = ControlBlockContext.Nested;
|
||||
node.statement = parseStatement();
|
||||
inIterationStatement = saveInIterationStatement;
|
||||
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
@ -1979,64 +2315,161 @@ module ts {
|
|||
var varOrInit = parseExpression(true);
|
||||
}
|
||||
}
|
||||
var forOrForInStatement: IterationStatement;
|
||||
if (parseOptional(SyntaxKind.InKeyword)) {
|
||||
var forInStat = <ForInStatement>createNode(SyntaxKind.ForInStatement, pos);
|
||||
var forInStatement = <ForInStatement>createNode(SyntaxKind.ForInStatement, pos);
|
||||
if (declarations) {
|
||||
if (declarations.length > 1) {
|
||||
error(Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement);
|
||||
}
|
||||
forInStat.declaration = declarations[0];
|
||||
forInStatement.declaration = declarations[0];
|
||||
}
|
||||
else {
|
||||
forInStat.variable = varOrInit;
|
||||
forInStatement.variable = varOrInit;
|
||||
}
|
||||
forInStat.expression = parseExpression();
|
||||
forInStatement.expression = parseExpression();
|
||||
parseExpected(SyntaxKind.CloseParenToken);
|
||||
forInStat.statement = parseStatement();
|
||||
return finishNode(forInStat);
|
||||
forOrForInStatement = forInStatement;
|
||||
}
|
||||
else {
|
||||
var forStat = <ForStatement>createNode(SyntaxKind.ForStatement, pos);
|
||||
if (declarations) forStat.declarations = declarations;
|
||||
if (varOrInit) forStat.initializer = varOrInit;
|
||||
var forStatement = <ForStatement>createNode(SyntaxKind.ForStatement, pos);
|
||||
if (declarations) forStatement.declarations = declarations;
|
||||
if (varOrInit) forStatement.initializer = varOrInit;
|
||||
parseExpected(SyntaxKind.SemicolonToken);
|
||||
if (token !== SyntaxKind.SemicolonToken && token !== SyntaxKind.CloseParenToken) {
|
||||
forStat.condition = parseExpression();
|
||||
forStatement.condition = parseExpression();
|
||||
}
|
||||
parseExpected(SyntaxKind.SemicolonToken);
|
||||
if (token !== SyntaxKind.CloseParenToken) {
|
||||
forStat.iterator = parseExpression();
|
||||
forStatement.iterator = parseExpression();
|
||||
}
|
||||
parseExpected(SyntaxKind.CloseParenToken);
|
||||
forStat.statement = parseStatement();
|
||||
return finishNode(forStat);
|
||||
forOrForInStatement = forStatement;
|
||||
}
|
||||
|
||||
var saveInIterationStatement = inIterationStatement;
|
||||
inIterationStatement = ControlBlockContext.Nested;
|
||||
forOrForInStatement.statement = parseStatement();
|
||||
inIterationStatement = saveInIterationStatement;
|
||||
|
||||
return finishNode(forOrForInStatement);
|
||||
}
|
||||
|
||||
function parseBreakOrContinueStatement(kind: SyntaxKind): BreakOrContinueStatement {
|
||||
var node = <BreakOrContinueStatement>createNode(kind);
|
||||
var errorCountBeforeStatement = file.syntacticErrors.length;
|
||||
var keywordStart = scanner.getTokenPos();
|
||||
var keywordLength = scanner.getTextPos() - keywordStart;
|
||||
parseExpected(kind === SyntaxKind.BreakStatement ? SyntaxKind.BreakKeyword : SyntaxKind.ContinueKeyword);
|
||||
if (!isSemicolon()) node.label = parseIdentifier();
|
||||
parseSemicolon();
|
||||
return finishNode(node);
|
||||
finishNode(node);
|
||||
|
||||
// In an ambient context, we will already give an error for having a statement.
|
||||
if (!inAmbientContext && errorCountBeforeStatement === file.syntacticErrors.length) {
|
||||
if (node.label) {
|
||||
checkBreakOrContinueStatementWithLabel(node);
|
||||
}
|
||||
else {
|
||||
checkBareBreakOrContinueStatement(node);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function checkBareBreakOrContinueStatement(node: BreakOrContinueStatement): void {
|
||||
if (node.kind === SyntaxKind.BreakStatement) {
|
||||
if (inIterationStatement === ControlBlockContext.Nested
|
||||
|| inSwitchStatement === ControlBlockContext.Nested) {
|
||||
return;
|
||||
}
|
||||
else if (inIterationStatement === ControlBlockContext.NotNested
|
||||
&& inSwitchStatement === ControlBlockContext.NotNested) {
|
||||
grammarErrorOnNode(node, Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement);
|
||||
return;
|
||||
}
|
||||
// Fall through
|
||||
}
|
||||
else if (node.kind === SyntaxKind.ContinueStatement) {
|
||||
if (inIterationStatement === ControlBlockContext.Nested) {
|
||||
return;
|
||||
}
|
||||
else if (inIterationStatement === ControlBlockContext.NotNested) {
|
||||
grammarErrorOnNode(node, Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement);
|
||||
return;
|
||||
}
|
||||
// Fall through
|
||||
}
|
||||
else {
|
||||
Debug.fail("checkAnonymousBreakOrContinueStatement");
|
||||
}
|
||||
|
||||
Debug.assert(inIterationStatement === ControlBlockContext.CrossingFunctionBoundary
|
||||
|| inSwitchStatement === ControlBlockContext.CrossingFunctionBoundary);
|
||||
grammarErrorOnNode(node, Diagnostics.Jump_target_cannot_cross_function_boundary);
|
||||
}
|
||||
|
||||
function checkBreakOrContinueStatementWithLabel(node: BreakOrContinueStatement): void {
|
||||
// For error specificity, if the label is not found, we want to distinguish whether it is because
|
||||
// it crossed a function boundary or it was simply not found. To do this, we pass false for
|
||||
// stopAtFunctionBoundary.
|
||||
var nodeIsNestedInLabel = labelledStatementInfo.nodeIsNestedInLabel(node.label,
|
||||
/*requireIterationStatement*/ node.kind === SyntaxKind.ContinueStatement,
|
||||
/*stopAtFunctionBoundary*/ false);
|
||||
if (nodeIsNestedInLabel === ControlBlockContext.Nested) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (nodeIsNestedInLabel === ControlBlockContext.CrossingFunctionBoundary) {
|
||||
grammarErrorOnNode(node, Diagnostics.Jump_target_cannot_cross_function_boundary);
|
||||
return;
|
||||
}
|
||||
|
||||
// It is NotNested
|
||||
if (node.kind === SyntaxKind.ContinueStatement) {
|
||||
grammarErrorOnNode(node, Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement);
|
||||
}
|
||||
else if (node.kind === SyntaxKind.BreakStatement) {
|
||||
grammarErrorOnNode(node, Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement);
|
||||
}
|
||||
else {
|
||||
Debug.fail("checkBreakOrContinueStatementWithLabel");
|
||||
}
|
||||
}
|
||||
|
||||
function parseReturnStatement(): ReturnStatement {
|
||||
var node = <ReturnStatement>createNode(SyntaxKind.ReturnStatement);
|
||||
var errorCountBeforeReturnStatement = file.syntacticErrors.length;
|
||||
var returnTokenStart = scanner.getTokenPos();
|
||||
var returnTokenLength = scanner.getTextPos() - returnTokenStart;
|
||||
|
||||
parseExpected(SyntaxKind.ReturnKeyword);
|
||||
if (!isSemicolon()) node.expression = parseExpression();
|
||||
parseSemicolon();
|
||||
|
||||
// In an ambient context, we will already give an error for having a statement.
|
||||
if (!inFunctionBody && !inAmbientContext && errorCountBeforeReturnStatement === file.syntacticErrors.length) {
|
||||
grammarErrorAtPos(returnTokenStart, returnTokenLength, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body);
|
||||
}
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseWithStatement(): WithStatement {
|
||||
var node = <WithStatement>createNode(SyntaxKind.WithStatement);
|
||||
var startPos = scanner.getTokenPos();
|
||||
parseExpected(SyntaxKind.WithKeyword);
|
||||
var endPos = scanner.getStartPos();
|
||||
parseExpected(SyntaxKind.OpenParenToken);
|
||||
node.expression = parseExpression();
|
||||
parseExpected(SyntaxKind.CloseParenToken);
|
||||
node.statement = parseStatement();
|
||||
return finishNode(node);
|
||||
node = finishNode(node);
|
||||
if (isInStrictMode) {
|
||||
// Strict mode code may not include a WithStatement. The occurrence of a WithStatement in such
|
||||
// a context is an
|
||||
grammarErrorAtPos(startPos, endPos - startPos, Diagnostics.with_statements_are_not_allowed_in_strict_mode)
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function parseCaseClause(): CaseOrDefaultClause {
|
||||
|
@ -2044,7 +2477,7 @@ module ts {
|
|||
parseExpected(SyntaxKind.CaseKeyword);
|
||||
node.expression = parseExpression();
|
||||
parseExpected(SyntaxKind.ColonToken);
|
||||
node.statements = parseList(ParsingContext.SwitchClauseStatements, parseStatement);
|
||||
node.statements = parseList(ParsingContext.SwitchClauseStatements, /*checkForStrictMode*/ false, parseStatement);
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
@ -2052,7 +2485,7 @@ module ts {
|
|||
var node = <CaseOrDefaultClause>createNode(SyntaxKind.DefaultClause);
|
||||
parseExpected(SyntaxKind.DefaultKeyword);
|
||||
parseExpected(SyntaxKind.ColonToken);
|
||||
node.statements = parseList(ParsingContext.SwitchClauseStatements, parseStatement);
|
||||
node.statements = parseList(ParsingContext.SwitchClauseStatements, /*checkForStrictMode*/ false, parseStatement);
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
@ -2067,7 +2500,12 @@ module ts {
|
|||
node.expression = parseExpression();
|
||||
parseExpected(SyntaxKind.CloseParenToken);
|
||||
parseExpected(SyntaxKind.OpenBraceToken);
|
||||
node.clauses = parseList(ParsingContext.SwitchClauses, parseCaseOrDefaultClause);
|
||||
|
||||
var saveInSwitchStatement = inSwitchStatement;
|
||||
inSwitchStatement = ControlBlockContext.Nested;
|
||||
node.clauses = parseList(ParsingContext.SwitchClauses, /*checkForStrictMode*/ false, parseCaseOrDefaultClause);
|
||||
inSwitchStatement = saveInSwitchStatement;
|
||||
|
||||
parseExpected(SyntaxKind.CloseBraceToken);
|
||||
|
||||
// Error on duplicate 'default' clauses.
|
||||
|
@ -2112,7 +2550,7 @@ module ts {
|
|||
function parseTokenAndBlock(token: SyntaxKind, kind: SyntaxKind): Block {
|
||||
var pos = getNodePos();
|
||||
parseExpected(token);
|
||||
var result = parseBlock(/* ignoreMissingOpenBrace */ false);
|
||||
var result = parseBlock(/* ignoreMissingOpenBrace */ false, /*checkForStrictMode*/ false);
|
||||
result.kind = kind;
|
||||
result.pos = pos;
|
||||
return result;
|
||||
|
@ -2127,7 +2565,7 @@ module ts {
|
|||
var typeAnnotationColonLength = scanner.getTextPos() - typeAnnotationColonStart;
|
||||
var typeAnnotation = parseTypeAnnotation();
|
||||
parseExpected(SyntaxKind.CloseParenToken);
|
||||
var result = <CatchBlock>parseBlock(/* ignoreMissingOpenBrace */ false);
|
||||
var result = <CatchBlock>parseBlock(/* ignoreMissingOpenBrace */ false, /*checkForStrictMode*/ false);
|
||||
result.kind = SyntaxKind.CatchBlock;
|
||||
result.pos = pos;
|
||||
result.variable = variable;
|
||||
|
@ -2135,6 +2573,11 @@ module ts {
|
|||
if (typeAnnotation) {
|
||||
errorAtPos(typeAnnotationColonStart, typeAnnotationColonLength, Diagnostics.Catch_clause_parameter_cannot_have_a_type_annotation);
|
||||
}
|
||||
if (isInStrictMode && isEvalOrArgumentsIdentifier(variable)) {
|
||||
// It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the
|
||||
// Catch production is eval or arguments
|
||||
reportInvalidUseInStrictMode(variable);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -2145,11 +2588,34 @@ module ts {
|
|||
return finishNode(node);
|
||||
}
|
||||
|
||||
function isIterationStatementStart(): boolean {
|
||||
return token === SyntaxKind.WhileKeyword || token === SyntaxKind.DoKeyword || token === SyntaxKind.ForKeyword;
|
||||
}
|
||||
|
||||
function parseStatementWithLabelSet(): Statement {
|
||||
labelledStatementInfo.pushCurrentLabelSet(isIterationStatementStart());
|
||||
var statement = parseStatement();
|
||||
labelledStatementInfo.pop();
|
||||
return statement;
|
||||
}
|
||||
|
||||
function isLabel(): boolean {
|
||||
return isIdentifier() && lookAhead(() => nextToken() === SyntaxKind.ColonToken);
|
||||
}
|
||||
|
||||
function parseLabelledStatement(): LabelledStatement {
|
||||
var node = <LabelledStatement>createNode(SyntaxKind.LabelledStatement);
|
||||
node.label = parseIdentifier();
|
||||
parseExpected(SyntaxKind.ColonToken);
|
||||
node.statement = parseStatement();
|
||||
|
||||
if (labelledStatementInfo.nodeIsNestedInLabel(node.label, /*requireIterationStatement*/ false, /*stopAtFunctionBoundary*/ true)) {
|
||||
grammarErrorOnNode(node.label, Diagnostics.Duplicate_label_0, getSourceTextOfNodeFromSourceText(sourceText, node.label));
|
||||
}
|
||||
labelledStatementInfo.addLabel(node.label);
|
||||
|
||||
// We only want to call parseStatementWithLabelSet when the label set is complete
|
||||
// Therefore, keep parsing labels until we know we're done.
|
||||
node.statement = isLabel() ? parseLabelledStatement() : parseStatementWithLabelSet();
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
@ -2207,7 +2673,7 @@ module ts {
|
|||
function parseStatement(): Statement {
|
||||
switch (token) {
|
||||
case SyntaxKind.OpenBraceToken:
|
||||
return parseBlock(/* ignoreMissingOpenBrace */ false);
|
||||
return parseBlock(/* ignoreMissingOpenBrace */ false, /*checkForStrictMode*/ false);
|
||||
case SyntaxKind.VarKeyword:
|
||||
return parseVariableStatement();
|
||||
case SyntaxKind.FunctionKeyword:
|
||||
|
@ -2239,7 +2705,7 @@ module ts {
|
|||
case SyntaxKind.DebuggerKeyword:
|
||||
return parseDebuggerStatement();
|
||||
default:
|
||||
if (isIdentifier() && lookAhead(() => nextToken() === SyntaxKind.ColonToken)) {
|
||||
if (isLabel()) {
|
||||
return parseLabelledStatement();
|
||||
}
|
||||
return parseExpressionStatement();
|
||||
|
@ -2285,6 +2751,11 @@ module ts {
|
|||
if (inAmbientContext && node.initializer && errorCountBeforeVariableDeclaration === file.syntacticErrors.length) {
|
||||
grammarErrorAtPos(initializerStart, initializerFirstTokenLength, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
|
||||
}
|
||||
if (isInStrictMode && isEvalOrArgumentsIdentifier(node.name)) {
|
||||
// It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code
|
||||
// and its Identifier is eval or arguments
|
||||
reportInvalidUseInStrictMode(node.name);
|
||||
}
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
@ -2315,6 +2786,11 @@ module ts {
|
|||
node.parameters = sig.parameters;
|
||||
node.type = sig.type;
|
||||
node.body = parseAndCheckFunctionBody(/*isConstructor*/ false);
|
||||
if (isInStrictMode && isEvalOrArgumentsIdentifier(node.name)) {
|
||||
// It is a SyntaxError to use within strict mode code the identifiers eval or arguments as the
|
||||
// Identifier of a FunctionDeclaration or FunctionExpression or as a formal parameter name(13.1)
|
||||
reportInvalidUseInStrictMode(node.name);
|
||||
}
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
@ -2657,7 +3133,7 @@ module ts {
|
|||
}
|
||||
var errorCountBeforeClassBody = file.syntacticErrors.length;
|
||||
if (parseExpected(SyntaxKind.OpenBraceToken)) {
|
||||
node.members = parseList(ParsingContext.ClassMembers, parseClassMemberDeclaration);
|
||||
node.members = parseList(ParsingContext.ClassMembers, /*checkForStrictMode*/ false, parseClassMemberDeclaration);
|
||||
parseExpected(SyntaxKind.CloseBraceToken);
|
||||
}
|
||||
else {
|
||||
|
@ -2757,7 +3233,7 @@ module ts {
|
|||
function parseModuleBody(): Block {
|
||||
var node = <Block>createNode(SyntaxKind.ModuleBlock);
|
||||
if (parseExpected(SyntaxKind.OpenBraceToken)) {
|
||||
node.statements = parseList(ParsingContext.ModuleElements, parseModuleElement);
|
||||
node.statements = parseList(ParsingContext.ModuleElements, /*checkForStrictMode*/ false, parseModuleElement);
|
||||
parseExpected(SyntaxKind.CloseBraceToken);
|
||||
}
|
||||
else {
|
||||
|
@ -3014,7 +3490,7 @@ module ts {
|
|||
var referenceComments = processReferenceComments();
|
||||
file.referencedFiles = referenceComments.referencedFiles;
|
||||
file.amdDependencies = referenceComments.amdDependencies;
|
||||
file.statements = parseList(ParsingContext.SourceElements, parseSourceElement);
|
||||
file.statements = parseList(ParsingContext.SourceElements, /*checkForStrictMode*/ true, parseSourceElement);
|
||||
file.externalModuleIndicator = getExternalModuleIndicator();
|
||||
file.nodeCount = nodeCount;
|
||||
file.identifierCount = identifierCount;
|
||||
|
|
|
@ -215,7 +215,9 @@ module ts {
|
|||
FirstReservedWord = BreakKeyword,
|
||||
LastReservedWord = WithKeyword,
|
||||
FirstKeyword = BreakKeyword,
|
||||
LastKeyword = StringKeyword
|
||||
LastKeyword = StringKeyword,
|
||||
FirstFutureReservedWord = ImplementsKeyword,
|
||||
LastFutureReservedWord = YieldKeyword
|
||||
}
|
||||
|
||||
export enum NodeFlags {
|
||||
|
@ -402,29 +404,29 @@ module ts {
|
|||
elseStatement?: Statement;
|
||||
}
|
||||
|
||||
export interface DoStatement extends Statement {
|
||||
export interface IterationStatement extends Statement {
|
||||
statement: Statement;
|
||||
}
|
||||
|
||||
export interface DoStatement extends IterationStatement {
|
||||
expression: Expression;
|
||||
}
|
||||
|
||||
export interface WhileStatement extends Statement {
|
||||
statement: Statement;
|
||||
export interface WhileStatement extends IterationStatement {
|
||||
expression: Expression;
|
||||
}
|
||||
|
||||
export interface ForStatement extends Statement {
|
||||
export interface ForStatement extends IterationStatement {
|
||||
declarations?: NodeArray<VariableDeclaration>;
|
||||
initializer?: Expression;
|
||||
condition?: Expression;
|
||||
iterator?: Expression;
|
||||
statement: Statement;
|
||||
}
|
||||
|
||||
export interface ForInStatement extends Statement {
|
||||
export interface ForInStatement extends IterationStatement {
|
||||
declaration?: VariableDeclaration;
|
||||
variable?: Expression;
|
||||
expression: Expression;
|
||||
statement: Statement;
|
||||
}
|
||||
|
||||
export interface BreakOrContinueStatement extends Statement {
|
||||
|
|
|
@ -89,7 +89,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
|||
result = compileResult;
|
||||
}, function (settings) {
|
||||
harnessCompiler.setCompilerSettings(tcSettings);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
|
|
|
@ -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,7 @@ module Harness {
|
|||
case 'declaration':
|
||||
options.declaration = !!setting.value;
|
||||
break;
|
||||
|
||||
case 'newline':
|
||||
case 'newlines':
|
||||
sys.newLine = setting.value;
|
||||
|
|
115
tests/baselines/reference/arrowFunctionsMissingTokens.errors.txt
Normal file
115
tests/baselines/reference/arrowFunctionsMissingTokens.errors.txt
Normal file
|
@ -0,0 +1,115 @@
|
|||
==== tests/cases/compiler/arrowFunctionsMissingTokens.ts (24 errors) ====
|
||||
|
||||
module missingArrowsWithCurly {
|
||||
var a = () { };
|
||||
~
|
||||
!!! '=>' expected.
|
||||
|
||||
var b = (): void { }
|
||||
~
|
||||
!!! '=>' expected.
|
||||
|
||||
var c = (x) { };
|
||||
~
|
||||
!!! '=>' expected.
|
||||
|
||||
var d = (x: number, y: string) { };
|
||||
~
|
||||
!!! '=>' expected.
|
||||
|
||||
var e = (x: number, y: string): void { };
|
||||
~
|
||||
!!! '=>' expected.
|
||||
}
|
||||
|
||||
module missingCurliesWithArrow {
|
||||
module withStatement {
|
||||
var a = () => var k = 10;};
|
||||
~~~
|
||||
!!! '{' expected.
|
||||
|
||||
var b = (): void => var k = 10;}
|
||||
~~~
|
||||
!!! '{' expected.
|
||||
|
||||
var c = (x) => var k = 10;};
|
||||
~~~
|
||||
!!! '{' expected.
|
||||
|
||||
var d = (x: number, y: string) => var k = 10;};
|
||||
~~~
|
||||
!!! '{' expected.
|
||||
|
||||
var e = (x: number, y: string): void => var k = 10;};
|
||||
~~~
|
||||
!!! '{' expected.
|
||||
|
||||
var f = () => var k = 10;}
|
||||
~~~
|
||||
!!! '{' expected.
|
||||
}
|
||||
|
||||
module withoutStatement {
|
||||
var a = () => };
|
||||
~
|
||||
!!! Expression expected.
|
||||
|
||||
var b = (): void => }
|
||||
~
|
||||
!!! Expression expected.
|
||||
|
||||
var c = (x) => };
|
||||
~
|
||||
!!! Expression expected.
|
||||
|
||||
var d = (x: number, y: string) => };
|
||||
~
|
||||
!!! Expression expected.
|
||||
|
||||
var e = (x: number, y: string): void => };
|
||||
~
|
||||
!!! Expression expected.
|
||||
|
||||
var f = () => }
|
||||
~
|
||||
!!! Expression expected.
|
||||
}
|
||||
~
|
||||
!!! Declaration or statement expected.
|
||||
}
|
||||
~
|
||||
!!! Declaration or statement expected.
|
||||
|
||||
module ce_nEst_pas_une_arrow_function {
|
||||
var a = ();
|
||||
~
|
||||
!!! Expression expected.
|
||||
|
||||
var b = (): void;
|
||||
~
|
||||
!!! '=>' expected.
|
||||
|
||||
var c = (x);
|
||||
~
|
||||
!!! Cannot find name 'x'.
|
||||
|
||||
var d = (x: number, y: string);
|
||||
~
|
||||
!!! '=>' expected.
|
||||
|
||||
var e = (x: number, y: string): void;
|
||||
~
|
||||
!!! '=>' expected.
|
||||
}
|
||||
|
||||
module okay {
|
||||
var a = () => { };
|
||||
|
||||
var b = (): void => { }
|
||||
|
||||
var c = (x) => { };
|
||||
|
||||
var d = (x: number, y: string) => { };
|
||||
|
||||
var e = (x: number, y: string): void => { };
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
//// [breakInIterationOrSwitchStatement1.ts]
|
||||
while (true) {
|
||||
break;
|
||||
}
|
||||
|
||||
//// [breakInIterationOrSwitchStatement1.js]
|
||||
while (true) {
|
||||
break;
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
//// [breakInIterationOrSwitchStatement2.ts]
|
||||
do {
|
||||
break;
|
||||
}
|
||||
while (true);
|
||||
|
||||
//// [breakInIterationOrSwitchStatement2.js]
|
||||
do {
|
||||
break;
|
||||
} while (true);
|
|
@ -1,9 +0,0 @@
|
|||
//// [breakInIterationOrSwitchStatement3.ts]
|
||||
for (;;) {
|
||||
break;
|
||||
}
|
||||
|
||||
//// [breakInIterationOrSwitchStatement3.js]
|
||||
for (;;) {
|
||||
break;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
==== tests/cases/compiler/breakInIterationOrSwitchStatement4.ts (1 errors) ====
|
||||
for (var i in something) {
|
||||
~~~~~~~~~
|
||||
!!! Cannot find name 'something'.
|
||||
break;
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
//// [breakInIterationOrSwitchStatement4.ts]
|
||||
for (var i in something) {
|
||||
break;
|
||||
}
|
||||
|
||||
//// [breakInIterationOrSwitchStatement4.js]
|
||||
for (var i in something) {
|
||||
break;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
//// [breakNotInIterationOrSwitchStatement1.ts]
|
||||
break;
|
||||
|
||||
//// [breakNotInIterationOrSwitchStatement1.js]
|
||||
break;
|
|
@ -1,13 +0,0 @@
|
|||
//// [breakNotInIterationOrSwitchStatement2.ts]
|
||||
while (true) {
|
||||
function f() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//// [breakNotInIterationOrSwitchStatement2.js]
|
||||
while (true) {
|
||||
function f() {
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
//// [breakTarget1.ts]
|
||||
target:
|
||||
break target;
|
||||
|
||||
//// [breakTarget1.js]
|
||||
target: break target;
|
|
@ -1,10 +0,0 @@
|
|||
//// [breakTarget2.ts]
|
||||
target:
|
||||
while (true) {
|
||||
break target;
|
||||
}
|
||||
|
||||
//// [breakTarget2.js]
|
||||
target: while (true) {
|
||||
break target;
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
//// [breakTarget3.ts]
|
||||
target1:
|
||||
target2:
|
||||
while (true) {
|
||||
break target1;
|
||||
}
|
||||
|
||||
//// [breakTarget3.js]
|
||||
target1: target2: while (true) {
|
||||
break target1;
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
//// [breakTarget4.ts]
|
||||
target1:
|
||||
target2:
|
||||
while (true) {
|
||||
break target2;
|
||||
}
|
||||
|
||||
//// [breakTarget4.js]
|
||||
target1: target2: while (true) {
|
||||
break target2;
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
//// [breakTarget5.ts]
|
||||
target:
|
||||
while (true) {
|
||||
function f() {
|
||||
while (true) {
|
||||
break target;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [breakTarget5.js]
|
||||
target: while (true) {
|
||||
function f() {
|
||||
while (true) {
|
||||
break target;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
//// [breakTarget6.ts]
|
||||
while (true) {
|
||||
break target;
|
||||
}
|
||||
|
||||
//// [breakTarget6.js]
|
||||
while (true) {
|
||||
break target;
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
==== tests/cases/compiler/constructorStaticParamNameErrors.ts (1 errors) ====
|
||||
'use strict'
|
||||
// static as constructor parameter name should give error if 'use strict'
|
||||
class test {
|
||||
constructor (static) { }
|
||||
~~~~~~
|
||||
!!! Identifier expected.
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
//// [constructorStaticParamNameErrors.ts]
|
||||
'use strict'
|
||||
// static as constructor parameter name should give error if 'use strict'
|
||||
class test {
|
||||
constructor (static) { }
|
||||
}
|
||||
|
||||
//// [constructorStaticParamNameErrors.js]
|
||||
'use strict';
|
||||
var test = (function () {
|
||||
function test(static) {
|
||||
}
|
||||
return test;
|
||||
})();
|
|
@ -1,9 +0,0 @@
|
|||
//// [continueInIterationStatement1.ts]
|
||||
while (true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//// [continueInIterationStatement1.js]
|
||||
while (true) {
|
||||
continue;
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
//// [continueInIterationStatement2.ts]
|
||||
do {
|
||||
continue;
|
||||
}
|
||||
while (true);
|
||||
|
||||
//// [continueInIterationStatement2.js]
|
||||
do {
|
||||
continue;
|
||||
} while (true);
|
|
@ -1,9 +0,0 @@
|
|||
//// [continueInIterationStatement3.ts]
|
||||
for (;;) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//// [continueInIterationStatement3.js]
|
||||
for (;;) {
|
||||
continue;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
==== tests/cases/compiler/continueInIterationStatement4.ts (1 errors) ====
|
||||
for (var i in something) {
|
||||
~~~~~~~~~
|
||||
!!! Cannot find name 'something'.
|
||||
continue;
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
//// [continueInIterationStatement4.ts]
|
||||
for (var i in something) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//// [continueInIterationStatement4.js]
|
||||
for (var i in something) {
|
||||
continue;
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
//// [continueLabel.ts]
|
||||
label1: for(var i = 0; i < 1; i++) {
|
||||
continue label1;
|
||||
}
|
||||
|
||||
//// [continueLabel.js]
|
||||
label1: for (var i = 0; i < 1; i++) {
|
||||
continue label1;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
//// [continueNotInIterationStatement1.ts]
|
||||
continue;
|
||||
|
||||
//// [continueNotInIterationStatement1.js]
|
||||
continue;
|
|
@ -1,13 +0,0 @@
|
|||
//// [continueNotInIterationStatement2.ts]
|
||||
while (true) {
|
||||
function f() {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//// [continueNotInIterationStatement2.js]
|
||||
while (true) {
|
||||
function f() {
|
||||
continue;
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
//// [continueNotInIterationStatement3.ts]
|
||||
switch (0) {
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
//// [continueNotInIterationStatement3.js]
|
||||
switch (0) {
|
||||
default:
|
||||
continue;
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
//// [continueNotInIterationStatement4.ts]
|
||||
TWO:
|
||||
while (true){
|
||||
var x = () => {
|
||||
continue TWO;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [continueNotInIterationStatement4.js]
|
||||
TWO: while (true) {
|
||||
var x = function () {
|
||||
continue TWO;
|
||||
};
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
//// [continueTarget1.ts]
|
||||
target:
|
||||
continue target;
|
||||
|
||||
//// [continueTarget1.js]
|
||||
target: continue target;
|
|
@ -1,10 +0,0 @@
|
|||
//// [continueTarget2.ts]
|
||||
target:
|
||||
while (true) {
|
||||
continue target;
|
||||
}
|
||||
|
||||
//// [continueTarget2.js]
|
||||
target: while (true) {
|
||||
continue target;
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
//// [continueTarget3.ts]
|
||||
target1:
|
||||
target2:
|
||||
while (true) {
|
||||
continue target1;
|
||||
}
|
||||
|
||||
//// [continueTarget3.js]
|
||||
target1: target2: while (true) {
|
||||
continue target1;
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
//// [continueTarget4.ts]
|
||||
target1:
|
||||
target2:
|
||||
while (true) {
|
||||
continue target2;
|
||||
}
|
||||
|
||||
//// [continueTarget4.js]
|
||||
target1: target2: while (true) {
|
||||
continue target2;
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
//// [continueTarget5.ts]
|
||||
target:
|
||||
while (true) {
|
||||
function f() {
|
||||
while (true) {
|
||||
continue target;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [continueTarget5.js]
|
||||
target: while (true) {
|
||||
function f() {
|
||||
while (true) {
|
||||
continue target;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
//// [continueTarget6.ts]
|
||||
while (true) {
|
||||
continue target;
|
||||
}
|
||||
|
||||
//// [continueTarget6.js]
|
||||
while (true) {
|
||||
continue target;
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
//// [duplicateLabel1.ts]
|
||||
target:
|
||||
target:
|
||||
while (true) {
|
||||
}
|
||||
|
||||
//// [duplicateLabel1.js]
|
||||
target: target: while (true) {
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
//// [duplicateLabel2.ts]
|
||||
target:
|
||||
while (true) {
|
||||
target:
|
||||
while (true) {
|
||||
}
|
||||
}
|
||||
|
||||
//// [duplicateLabel2.js]
|
||||
target: while (true) {
|
||||
target: while (true) {
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
//// [duplicateLabel3.ts]
|
||||
target:
|
||||
while (true) {
|
||||
function f() {
|
||||
target:
|
||||
while (true) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [duplicateLabel3.js]
|
||||
target: while (true) {
|
||||
function f() {
|
||||
target: while (true) {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
//// [duplicateLabel4.ts]
|
||||
target:
|
||||
while (true) {
|
||||
}
|
||||
|
||||
target:
|
||||
while (true) {
|
||||
}
|
||||
|
||||
//// [duplicateLabel4.js]
|
||||
target: while (true) {
|
||||
}
|
||||
target: while (true) {
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
==== tests/cases/compiler/duplicateObjectLiteralProperty.ts (8 errors) ====
|
||||
==== tests/cases/compiler/duplicateObjectLiteralProperty.ts (9 errors) ====
|
||||
var x = {
|
||||
a: 1,
|
||||
b: true, // OK
|
||||
|
@ -30,6 +30,8 @@
|
|||
~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~
|
||||
!!! An object literal cannot have multiple get/set accessors with the same name.
|
||||
~
|
||||
!!! Duplicate identifier 'a'.
|
||||
};
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
==== tests/cases/compiler/duplicatePropertiesInStrictMode.ts (2 errors) ====
|
||||
"use strict";
|
||||
var x = {
|
||||
x: 1,
|
||||
x: 2
|
||||
~
|
||||
!!! An object literal cannot have multiple properties with the same name in strict mode.
|
||||
~
|
||||
!!! Duplicate identifier 'x'.
|
||||
}
|
|
@ -1,11 +1,9 @@
|
|||
==== tests/cases/compiler/emptyMemberAccess.ts (2 errors) ====
|
||||
==== tests/cases/compiler/emptyMemberAccess.ts (1 errors) ====
|
||||
function getObj() {
|
||||
|
||||
().toString();
|
||||
~
|
||||
!!! '=>' expected.
|
||||
~~~~~~~~
|
||||
!!! Cannot find name 'toString'.
|
||||
~
|
||||
!!! Expression expected.
|
||||
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
declare class foo();
|
||||
~
|
||||
!!! '{' expected.
|
||||
~
|
||||
!!! '=>' expected.
|
||||
~
|
||||
!!! Expression expected.
|
||||
function foo() {}
|
||||
~~~
|
||||
!!! Duplicate identifier 'foo'.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
==== tests/cases/compiler/fatarrowfunctionsErrors.ts (25 errors) ====
|
||||
==== tests/cases/compiler/fatarrowfunctionsErrors.ts (18 errors) ====
|
||||
foo((...Far:any[])=>{return 0;})
|
||||
~~~
|
||||
!!! Cannot find name 'foo'.
|
||||
|
@ -39,25 +39,11 @@
|
|||
~
|
||||
!!! '=>' expected.
|
||||
var x2 = (a:number) :void {};
|
||||
~
|
||||
!!! ')' expected.
|
||||
~
|
||||
!!! ',' expected.
|
||||
~
|
||||
!!! Variable declaration expected.
|
||||
~~~~
|
||||
!!! Variable declaration expected.
|
||||
~
|
||||
!!! Cannot find name 'a'.
|
||||
~
|
||||
!!! '=>' expected.
|
||||
var x3 = (a:number) {};
|
||||
~
|
||||
!!! ')' expected.
|
||||
~
|
||||
!!! ',' expected.
|
||||
~
|
||||
!!! Variable declaration expected.
|
||||
~
|
||||
!!! Cannot find name 'a'.
|
||||
!!! '=>' expected.
|
||||
var x4= (...a: any[]) { };
|
||||
~
|
||||
!!! '=>' expected.
|
|
@ -19,8 +19,8 @@
|
|||
return 1;
|
||||
~~~~~~
|
||||
!!! Property or signature expected.
|
||||
~~~~~~~~~
|
||||
!!! 'return' statement has no containing function.
|
||||
~~~~~~
|
||||
!!! A 'return' statement can only be used within a function body.
|
||||
};
|
||||
~
|
||||
!!! Declaration or statement expected.
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
==== tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts (6 errors) ====
|
||||
// All errors
|
||||
|
||||
// naked break not allowed
|
||||
break;
|
||||
~~~~~~
|
||||
!!! A 'break' statement can only be used within an enclosing iteration or switch statement.
|
||||
|
||||
// non-existent label
|
||||
ONE:
|
||||
do break TWO; while (true)
|
||||
~~~~~~~~~~
|
||||
!!! A 'break' statement can only jump to a label of an enclosing statement.
|
||||
|
||||
// break from inside function
|
||||
TWO:
|
||||
do {
|
||||
var x = () => {
|
||||
break TWO;
|
||||
~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}while (true)
|
||||
|
||||
THREE:
|
||||
do {
|
||||
var fn = function () {
|
||||
break THREE;
|
||||
~~~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}while (true)
|
||||
|
||||
// break forward
|
||||
do {
|
||||
break FIVE;
|
||||
~~~~~~~~~~~
|
||||
!!! A 'break' statement can only jump to a label of an enclosing statement.
|
||||
FIVE:
|
||||
do { } while (true)
|
||||
}while (true)
|
||||
|
||||
// label on non-loop statement
|
||||
NINE:
|
||||
var y = 12;
|
||||
|
||||
do {
|
||||
break NINE;
|
||||
~~~~~~~~~~~
|
||||
!!! A 'break' statement can only jump to a label of an enclosing statement.
|
||||
}while (true)
|
|
@ -1,64 +0,0 @@
|
|||
//// [invalidDoWhileBreakStatements.ts]
|
||||
// All errors
|
||||
|
||||
// naked break not allowed
|
||||
break;
|
||||
|
||||
// non-existent label
|
||||
ONE:
|
||||
do break TWO; while (true)
|
||||
|
||||
// break from inside function
|
||||
TWO:
|
||||
do {
|
||||
var x = () => {
|
||||
break TWO;
|
||||
}
|
||||
}while (true)
|
||||
|
||||
THREE:
|
||||
do {
|
||||
var fn = function () {
|
||||
break THREE;
|
||||
}
|
||||
}while (true)
|
||||
|
||||
// break forward
|
||||
do {
|
||||
break FIVE;
|
||||
FIVE:
|
||||
do { } while (true)
|
||||
}while (true)
|
||||
|
||||
// label on non-loop statement
|
||||
NINE:
|
||||
var y = 12;
|
||||
|
||||
do {
|
||||
break NINE;
|
||||
}while (true)
|
||||
|
||||
//// [invalidDoWhileBreakStatements.js]
|
||||
break;
|
||||
ONE: do
|
||||
break TWO;
|
||||
while (true);
|
||||
TWO: do {
|
||||
var x = function () {
|
||||
break TWO;
|
||||
};
|
||||
} while (true);
|
||||
THREE: do {
|
||||
var fn = function () {
|
||||
break THREE;
|
||||
};
|
||||
} while (true);
|
||||
do {
|
||||
break FIVE;
|
||||
FIVE: do {
|
||||
} while (true);
|
||||
} while (true);
|
||||
NINE: var y = 12;
|
||||
do {
|
||||
break NINE;
|
||||
} while (true);
|
|
@ -0,0 +1,51 @@
|
|||
==== tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts (6 errors) ====
|
||||
// All errors
|
||||
|
||||
// naked continue not allowed
|
||||
continue;
|
||||
~~~~~~~~~
|
||||
!!! A 'continue' statement can only be used within an enclosing iteration statement.
|
||||
|
||||
// non-existent label
|
||||
ONE:
|
||||
do continue TWO; while (true)
|
||||
~~~~~~~~~~~~~
|
||||
!!! A 'continue' statement can only jump to a label of an enclosing iteration statement.
|
||||
|
||||
// continue from inside function
|
||||
TWO:
|
||||
do {
|
||||
var x = () => {
|
||||
continue TWO;
|
||||
~~~~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}while (true)
|
||||
|
||||
THREE:
|
||||
do {
|
||||
var fn = function () {
|
||||
continue THREE;
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}while (true)
|
||||
|
||||
// continue forward
|
||||
do {
|
||||
continue FIVE;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! A 'continue' statement can only jump to a label of an enclosing iteration statement.
|
||||
FIVE:
|
||||
do { } while (true)
|
||||
}while (true)
|
||||
|
||||
// label on non-loop statement
|
||||
NINE:
|
||||
var y = 12;
|
||||
|
||||
do {
|
||||
continue NINE;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! A 'continue' statement can only jump to a label of an enclosing iteration statement.
|
||||
}while (true)
|
|
@ -1,64 +0,0 @@
|
|||
//// [invalidDoWhileContinueStatements.ts]
|
||||
// All errors
|
||||
|
||||
// naked continue not allowed
|
||||
continue;
|
||||
|
||||
// non-existent label
|
||||
ONE:
|
||||
do continue TWO; while (true)
|
||||
|
||||
// continue from inside function
|
||||
TWO:
|
||||
do {
|
||||
var x = () => {
|
||||
continue TWO;
|
||||
}
|
||||
}while (true)
|
||||
|
||||
THREE:
|
||||
do {
|
||||
var fn = function () {
|
||||
continue THREE;
|
||||
}
|
||||
}while (true)
|
||||
|
||||
// continue forward
|
||||
do {
|
||||
continue FIVE;
|
||||
FIVE:
|
||||
do { } while (true)
|
||||
}while (true)
|
||||
|
||||
// label on non-loop statement
|
||||
NINE:
|
||||
var y = 12;
|
||||
|
||||
do {
|
||||
continue NINE;
|
||||
}while (true)
|
||||
|
||||
//// [invalidDoWhileContinueStatements.js]
|
||||
continue;
|
||||
ONE: do
|
||||
continue TWO;
|
||||
while (true);
|
||||
TWO: do {
|
||||
var x = function () {
|
||||
continue TWO;
|
||||
};
|
||||
} while (true);
|
||||
THREE: do {
|
||||
var fn = function () {
|
||||
continue THREE;
|
||||
};
|
||||
} while (true);
|
||||
do {
|
||||
continue FIVE;
|
||||
FIVE: do {
|
||||
} while (true);
|
||||
} while (true);
|
||||
NINE: var y = 12;
|
||||
do {
|
||||
continue NINE;
|
||||
} while (true);
|
|
@ -0,0 +1,50 @@
|
|||
==== tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts (6 errors) ====
|
||||
// All errors
|
||||
|
||||
// naked break not allowed
|
||||
break;
|
||||
~~~~~~
|
||||
!!! A 'break' statement can only be used within an enclosing iteration or switch statement.
|
||||
|
||||
// non-existent label
|
||||
ONE:
|
||||
for(;;) break TWO;
|
||||
~~~~~~~~~~
|
||||
!!! A 'break' statement can only jump to a label of an enclosing statement.
|
||||
|
||||
// break from inside function
|
||||
TWO:
|
||||
for(;;) {
|
||||
var x = () => {
|
||||
break TWO;
|
||||
~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}
|
||||
|
||||
THREE:
|
||||
for(;;) {
|
||||
var fn = function () {
|
||||
break THREE;
|
||||
~~~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}
|
||||
|
||||
// break forward
|
||||
for(;;) {
|
||||
break FIVE;
|
||||
~~~~~~~~~~~
|
||||
!!! A 'break' statement can only jump to a label of an enclosing statement.
|
||||
FIVE:
|
||||
for (; ;) { }
|
||||
}
|
||||
// label on non-loop statement
|
||||
NINE:
|
||||
var y = 12;
|
||||
|
||||
for(;;) {
|
||||
break NINE;
|
||||
~~~~~~~~~~~
|
||||
!!! A 'break' statement can only jump to a label of an enclosing statement.
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
//// [invalidForBreakStatements.ts]
|
||||
// All errors
|
||||
|
||||
// naked break not allowed
|
||||
break;
|
||||
|
||||
// non-existent label
|
||||
ONE:
|
||||
for(;;) break TWO;
|
||||
|
||||
// break from inside function
|
||||
TWO:
|
||||
for(;;) {
|
||||
var x = () => {
|
||||
break TWO;
|
||||
}
|
||||
}
|
||||
|
||||
THREE:
|
||||
for(;;) {
|
||||
var fn = function () {
|
||||
break THREE;
|
||||
}
|
||||
}
|
||||
|
||||
// break forward
|
||||
for(;;) {
|
||||
break FIVE;
|
||||
FIVE:
|
||||
for (; ;) { }
|
||||
}
|
||||
// label on non-loop statement
|
||||
NINE:
|
||||
var y = 12;
|
||||
|
||||
for(;;) {
|
||||
break NINE;
|
||||
}
|
||||
|
||||
//// [invalidForBreakStatements.js]
|
||||
break;
|
||||
ONE: for (;;)
|
||||
break TWO;
|
||||
TWO: for (;;) {
|
||||
var x = function () {
|
||||
break TWO;
|
||||
};
|
||||
}
|
||||
THREE: for (;;) {
|
||||
var fn = function () {
|
||||
break THREE;
|
||||
};
|
||||
}
|
||||
for (;;) {
|
||||
break FIVE;
|
||||
FIVE: for (;;) {
|
||||
}
|
||||
}
|
||||
NINE: var y = 12;
|
||||
for (;;) {
|
||||
break NINE;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
==== tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts (6 errors) ====
|
||||
// All errors
|
||||
|
||||
// naked continue not allowed
|
||||
continue;
|
||||
~~~~~~~~~
|
||||
!!! A 'continue' statement can only be used within an enclosing iteration statement.
|
||||
|
||||
// non-existent label
|
||||
ONE:
|
||||
for(;;) continue TWO;
|
||||
~~~~~~~~~~~~~
|
||||
!!! A 'continue' statement can only jump to a label of an enclosing iteration statement.
|
||||
|
||||
// continue from inside function
|
||||
TWO:
|
||||
for(;;) {
|
||||
var x = () => {
|
||||
continue TWO;
|
||||
~~~~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}
|
||||
|
||||
THREE:
|
||||
for(;;) {
|
||||
var fn = function () {
|
||||
continue THREE;
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}
|
||||
|
||||
// continue forward
|
||||
for(;;) {
|
||||
continue FIVE;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! A 'continue' statement can only jump to a label of an enclosing iteration statement.
|
||||
FIVE:
|
||||
for (; ;) { }
|
||||
}
|
||||
// label on non-loop statement
|
||||
NINE:
|
||||
var y = 12;
|
||||
|
||||
for(;;) {
|
||||
continue NINE;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! A 'continue' statement can only jump to a label of an enclosing iteration statement.
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
//// [invalidForContinueStatements.ts]
|
||||
// All errors
|
||||
|
||||
// naked continue not allowed
|
||||
continue;
|
||||
|
||||
// non-existent label
|
||||
ONE:
|
||||
for(;;) continue TWO;
|
||||
|
||||
// continue from inside function
|
||||
TWO:
|
||||
for(;;) {
|
||||
var x = () => {
|
||||
continue TWO;
|
||||
}
|
||||
}
|
||||
|
||||
THREE:
|
||||
for(;;) {
|
||||
var fn = function () {
|
||||
continue THREE;
|
||||
}
|
||||
}
|
||||
|
||||
// continue forward
|
||||
for(;;) {
|
||||
continue FIVE;
|
||||
FIVE:
|
||||
for (; ;) { }
|
||||
}
|
||||
// label on non-loop statement
|
||||
NINE:
|
||||
var y = 12;
|
||||
|
||||
for(;;) {
|
||||
continue NINE;
|
||||
}
|
||||
|
||||
//// [invalidForContinueStatements.js]
|
||||
continue;
|
||||
ONE: for (;;)
|
||||
continue TWO;
|
||||
TWO: for (;;) {
|
||||
var x = function () {
|
||||
continue TWO;
|
||||
};
|
||||
}
|
||||
THREE: for (;;) {
|
||||
var fn = function () {
|
||||
continue THREE;
|
||||
};
|
||||
}
|
||||
for (;;) {
|
||||
continue FIVE;
|
||||
FIVE: for (;;) {
|
||||
}
|
||||
}
|
||||
NINE: var y = 12;
|
||||
for (;;) {
|
||||
continue NINE;
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
==== tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts (6 errors) ====
|
||||
// All errors
|
||||
|
||||
// naked break not allowed
|
||||
break;
|
||||
~~~~~~
|
||||
!!! A 'break' statement can only be used within an enclosing iteration or switch statement.
|
||||
|
||||
// non-existent label
|
||||
ONE:
|
||||
for (var x in {}) break TWO;
|
||||
~~~~~~~~~~
|
||||
!!! A 'break' statement can only jump to a label of an enclosing statement.
|
||||
|
||||
// break from inside function
|
||||
TWO:
|
||||
for (var x in {}) {
|
||||
var fn = () => {
|
||||
break TWO;
|
||||
~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}
|
||||
|
||||
THREE:
|
||||
for (var x in {}) {
|
||||
var fn = function () {
|
||||
break THREE;
|
||||
~~~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}
|
||||
|
||||
// break forward
|
||||
for (var x in {}) {
|
||||
break FIVE;
|
||||
~~~~~~~~~~~
|
||||
!!! A 'break' statement can only jump to a label of an enclosing statement.
|
||||
FIVE:
|
||||
for (var x in {}) { }
|
||||
}
|
||||
|
||||
// label on non-loop statement
|
||||
NINE:
|
||||
var y = 12;
|
||||
|
||||
for (var x in {}) {
|
||||
break NINE;
|
||||
~~~~~~~~~~~
|
||||
!!! A 'break' statement can only jump to a label of an enclosing statement.
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
//// [invalidForInBreakStatements.ts]
|
||||
// All errors
|
||||
|
||||
// naked break not allowed
|
||||
break;
|
||||
|
||||
// non-existent label
|
||||
ONE:
|
||||
for (var x in {}) break TWO;
|
||||
|
||||
// break from inside function
|
||||
TWO:
|
||||
for (var x in {}) {
|
||||
var fn = () => {
|
||||
break TWO;
|
||||
}
|
||||
}
|
||||
|
||||
THREE:
|
||||
for (var x in {}) {
|
||||
var fn = function () {
|
||||
break THREE;
|
||||
}
|
||||
}
|
||||
|
||||
// break forward
|
||||
for (var x in {}) {
|
||||
break FIVE;
|
||||
FIVE:
|
||||
for (var x in {}) { }
|
||||
}
|
||||
|
||||
// label on non-loop statement
|
||||
NINE:
|
||||
var y = 12;
|
||||
|
||||
for (var x in {}) {
|
||||
break NINE;
|
||||
}
|
||||
|
||||
//// [invalidForInBreakStatements.js]
|
||||
break;
|
||||
ONE: for (var x in {})
|
||||
break TWO;
|
||||
TWO: for (var x in {}) {
|
||||
var fn = function () {
|
||||
break TWO;
|
||||
};
|
||||
}
|
||||
THREE: for (var x in {}) {
|
||||
var fn = function () {
|
||||
break THREE;
|
||||
};
|
||||
}
|
||||
for (var x in {}) {
|
||||
break FIVE;
|
||||
FIVE: for (var x in {}) {
|
||||
}
|
||||
}
|
||||
NINE: var y = 12;
|
||||
for (var x in {}) {
|
||||
break NINE;
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
==== tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts (6 errors) ====
|
||||
// All errors
|
||||
|
||||
// naked continue not allowed
|
||||
continue;
|
||||
~~~~~~~~~
|
||||
!!! A 'continue' statement can only be used within an enclosing iteration statement.
|
||||
|
||||
// non-existent label
|
||||
ONE:
|
||||
for (var x in {}) continue TWO;
|
||||
~~~~~~~~~~~~~
|
||||
!!! A 'continue' statement can only jump to a label of an enclosing iteration statement.
|
||||
|
||||
// continue from inside function
|
||||
TWO:
|
||||
for (var x in {}) {
|
||||
var fn = () => {
|
||||
continue TWO;
|
||||
~~~~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}
|
||||
|
||||
THREE:
|
||||
for (var x in {}) {
|
||||
var fn = function () {
|
||||
continue THREE;
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}
|
||||
|
||||
// continue forward
|
||||
for (var x in {}) {
|
||||
continue FIVE;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! A 'continue' statement can only jump to a label of an enclosing iteration statement.
|
||||
FIVE:
|
||||
for (var x in {}) { }
|
||||
}
|
||||
|
||||
// label on non-loop statement
|
||||
NINE:
|
||||
var y = 12;
|
||||
|
||||
for (var x in {}) {
|
||||
continue NINE;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! A 'continue' statement can only jump to a label of an enclosing iteration statement.
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
//// [invalidForInContinueStatements.ts]
|
||||
// All errors
|
||||
|
||||
// naked continue not allowed
|
||||
continue;
|
||||
|
||||
// non-existent label
|
||||
ONE:
|
||||
for (var x in {}) continue TWO;
|
||||
|
||||
// continue from inside function
|
||||
TWO:
|
||||
for (var x in {}) {
|
||||
var fn = () => {
|
||||
continue TWO;
|
||||
}
|
||||
}
|
||||
|
||||
THREE:
|
||||
for (var x in {}) {
|
||||
var fn = function () {
|
||||
continue THREE;
|
||||
}
|
||||
}
|
||||
|
||||
// continue forward
|
||||
for (var x in {}) {
|
||||
continue FIVE;
|
||||
FIVE:
|
||||
for (var x in {}) { }
|
||||
}
|
||||
|
||||
// label on non-loop statement
|
||||
NINE:
|
||||
var y = 12;
|
||||
|
||||
for (var x in {}) {
|
||||
continue NINE;
|
||||
}
|
||||
|
||||
//// [invalidForInContinueStatements.js]
|
||||
continue;
|
||||
ONE: for (var x in {})
|
||||
continue TWO;
|
||||
TWO: for (var x in {}) {
|
||||
var fn = function () {
|
||||
continue TWO;
|
||||
};
|
||||
}
|
||||
THREE: for (var x in {}) {
|
||||
var fn = function () {
|
||||
continue THREE;
|
||||
};
|
||||
}
|
||||
for (var x in {}) {
|
||||
continue FIVE;
|
||||
FIVE: for (var x in {}) {
|
||||
}
|
||||
}
|
||||
NINE: var y = 12;
|
||||
for (var x in {}) {
|
||||
continue NINE;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
==== tests/cases/conformance/statements/continueStatements/invalidSwitchContinueStatement.ts (1 errors) ====
|
||||
// continue is not allowed in a switch statement
|
||||
|
||||
switch (12) {
|
||||
case 5:
|
||||
continue;
|
||||
~~~~~~~~~
|
||||
!!! A 'continue' statement can only be used within an enclosing iteration statement.
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
//// [invalidSwitchContinueStatement.ts]
|
||||
// continue is not allowed in a switch statement
|
||||
|
||||
switch (12) {
|
||||
case 5:
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//// [invalidSwitchContinueStatement.js]
|
||||
switch (12) {
|
||||
case 5:
|
||||
continue;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
==== tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts (5 errors) ====
|
||||
==== tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts (4 errors) ====
|
||||
function fn() {
|
||||
try {
|
||||
} catch { // syntax error, missing '(x)'
|
||||
|
@ -10,9 +10,7 @@
|
|||
~~~~~
|
||||
!!! Statement expected.
|
||||
~
|
||||
!!! ';' expected.
|
||||
~
|
||||
!!! Cannot find name 'x'.
|
||||
!!! '=>' expected.
|
||||
|
||||
finally{ } // error missing try
|
||||
~~~~~~~
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
==== tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts (6 errors) ====
|
||||
// All errors
|
||||
|
||||
// naked break not allowed
|
||||
break;
|
||||
~~~~~~
|
||||
!!! A 'break' statement can only be used within an enclosing iteration or switch statement.
|
||||
|
||||
// non-existent label
|
||||
ONE:
|
||||
while (true) break TWO;
|
||||
~~~~~~~~~~
|
||||
!!! A 'break' statement can only jump to a label of an enclosing statement.
|
||||
|
||||
// break from inside function
|
||||
TWO:
|
||||
while (true){
|
||||
var x = () => {
|
||||
break TWO;
|
||||
~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}
|
||||
|
||||
THREE:
|
||||
while (true) {
|
||||
var fn = function () {
|
||||
break THREE;
|
||||
~~~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}
|
||||
|
||||
// break forward
|
||||
while (true) {
|
||||
break FIVE;
|
||||
~~~~~~~~~~~
|
||||
!!! A 'break' statement can only jump to a label of an enclosing statement.
|
||||
FIVE:
|
||||
while (true) { }
|
||||
}
|
||||
|
||||
// label on non-loop statement
|
||||
NINE:
|
||||
var y = 12;
|
||||
|
||||
while (true) {
|
||||
break NINE;
|
||||
~~~~~~~~~~~
|
||||
!!! A 'break' statement can only jump to a label of an enclosing statement.
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
//// [invalidWhileBreakStatements.ts]
|
||||
// All errors
|
||||
|
||||
// naked break not allowed
|
||||
break;
|
||||
|
||||
// non-existent label
|
||||
ONE:
|
||||
while (true) break TWO;
|
||||
|
||||
// break from inside function
|
||||
TWO:
|
||||
while (true){
|
||||
var x = () => {
|
||||
break TWO;
|
||||
}
|
||||
}
|
||||
|
||||
THREE:
|
||||
while (true) {
|
||||
var fn = function () {
|
||||
break THREE;
|
||||
}
|
||||
}
|
||||
|
||||
// break forward
|
||||
while (true) {
|
||||
break FIVE;
|
||||
FIVE:
|
||||
while (true) { }
|
||||
}
|
||||
|
||||
// label on non-loop statement
|
||||
NINE:
|
||||
var y = 12;
|
||||
|
||||
while (true) {
|
||||
break NINE;
|
||||
}
|
||||
|
||||
//// [invalidWhileBreakStatements.js]
|
||||
break;
|
||||
ONE: while (true)
|
||||
break TWO;
|
||||
TWO: while (true) {
|
||||
var x = function () {
|
||||
break TWO;
|
||||
};
|
||||
}
|
||||
THREE: while (true) {
|
||||
var fn = function () {
|
||||
break THREE;
|
||||
};
|
||||
}
|
||||
while (true) {
|
||||
break FIVE;
|
||||
FIVE: while (true) {
|
||||
}
|
||||
}
|
||||
NINE: var y = 12;
|
||||
while (true) {
|
||||
break NINE;
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
==== tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts (6 errors) ====
|
||||
// All errors
|
||||
|
||||
// naked continue not allowed
|
||||
continue;
|
||||
~~~~~~~~~
|
||||
!!! A 'continue' statement can only be used within an enclosing iteration statement.
|
||||
|
||||
// non-existent label
|
||||
ONE:
|
||||
while (true) continue TWO;
|
||||
~~~~~~~~~~~~~
|
||||
!!! A 'continue' statement can only jump to a label of an enclosing iteration statement.
|
||||
|
||||
// continue from inside function
|
||||
TWO:
|
||||
while (true){
|
||||
var x = () => {
|
||||
continue TWO;
|
||||
~~~~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}
|
||||
|
||||
THREE:
|
||||
while (true) {
|
||||
var fn = function () {
|
||||
continue THREE;
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}
|
||||
|
||||
// continue forward
|
||||
while (true) {
|
||||
continue FIVE;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! A 'continue' statement can only jump to a label of an enclosing iteration statement.
|
||||
FIVE:
|
||||
while (true) { }
|
||||
}
|
||||
|
||||
// label on non-loop statement
|
||||
NINE:
|
||||
var y = 12;
|
||||
|
||||
while (true) {
|
||||
continue NINE;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! A 'continue' statement can only jump to a label of an enclosing iteration statement.
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
//// [invalidWhileContinueStatements.ts]
|
||||
// All errors
|
||||
|
||||
// naked continue not allowed
|
||||
continue;
|
||||
|
||||
// non-existent label
|
||||
ONE:
|
||||
while (true) continue TWO;
|
||||
|
||||
// continue from inside function
|
||||
TWO:
|
||||
while (true){
|
||||
var x = () => {
|
||||
continue TWO;
|
||||
}
|
||||
}
|
||||
|
||||
THREE:
|
||||
while (true) {
|
||||
var fn = function () {
|
||||
continue THREE;
|
||||
}
|
||||
}
|
||||
|
||||
// continue forward
|
||||
while (true) {
|
||||
continue FIVE;
|
||||
FIVE:
|
||||
while (true) { }
|
||||
}
|
||||
|
||||
// label on non-loop statement
|
||||
NINE:
|
||||
var y = 12;
|
||||
|
||||
while (true) {
|
||||
continue NINE;
|
||||
}
|
||||
|
||||
//// [invalidWhileContinueStatements.js]
|
||||
continue;
|
||||
ONE: while (true)
|
||||
continue TWO;
|
||||
TWO: while (true) {
|
||||
var x = function () {
|
||||
continue TWO;
|
||||
};
|
||||
}
|
||||
THREE: while (true) {
|
||||
var fn = function () {
|
||||
continue THREE;
|
||||
};
|
||||
}
|
||||
while (true) {
|
||||
continue FIVE;
|
||||
FIVE: while (true) {
|
||||
}
|
||||
}
|
||||
NINE: var y = 12;
|
||||
while (true) {
|
||||
continue NINE;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
==== tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts (41 errors) ====
|
||||
==== tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts (59 errors) ====
|
||||
|
||||
// Multiple properties with the same name
|
||||
var e1 = { a: 0, a: 0 };
|
||||
|
@ -59,57 +59,93 @@
|
|||
// Accessor and property with the same name
|
||||
var f1 = { a: 0, get a() { return 0; } };
|
||||
~
|
||||
!!! An object literal cannot have property and accessor with the same name.
|
||||
~
|
||||
!!! Duplicate identifier 'a'.
|
||||
var f2 = { a: '', get a() { return ''; } };
|
||||
~
|
||||
!!! An object literal cannot have property and accessor with the same name.
|
||||
~
|
||||
!!! Duplicate identifier 'a'.
|
||||
var f3 = { a: 0, get a() { return ''; } };
|
||||
~
|
||||
!!! An object literal cannot have property and accessor with the same name.
|
||||
~
|
||||
!!! Duplicate identifier 'a'.
|
||||
var f4 = { a: true, get a() { return false; } };
|
||||
~
|
||||
!!! An object literal cannot have property and accessor with the same name.
|
||||
~
|
||||
!!! Duplicate identifier 'a'.
|
||||
var f5 = { a: {}, get a() { return {}; } };
|
||||
~
|
||||
!!! An object literal cannot have property and accessor with the same name.
|
||||
~
|
||||
!!! Duplicate identifier 'a'.
|
||||
var f6 = { a: 0, get 'a'() { return 0; } };
|
||||
~~~
|
||||
!!! An object literal cannot have property and accessor with the same name.
|
||||
~~~
|
||||
!!! Duplicate identifier ''a''.
|
||||
var f7 = { 'a': 0, get a() { return 0; } };
|
||||
~
|
||||
!!! An object literal cannot have property and accessor with the same name.
|
||||
~
|
||||
!!! Duplicate identifier 'a'.
|
||||
var f8 = { 'a': 0, get "a"() { return 0; } };
|
||||
~~~
|
||||
!!! An object literal cannot have property and accessor with the same name.
|
||||
~~~
|
||||
!!! Duplicate identifier '"a"'.
|
||||
var f9 = { 'a': 0, get 'a'() { return 0; } };
|
||||
~~~
|
||||
!!! An object literal cannot have property and accessor with the same name.
|
||||
~~~
|
||||
!!! Duplicate identifier ''a''.
|
||||
var f10 = { "a": 0, get 'a'() { return 0; } };
|
||||
~~~
|
||||
!!! An object literal cannot have property and accessor with the same name.
|
||||
~~~
|
||||
!!! Duplicate identifier ''a''.
|
||||
var f11 = { 1.0: 0, get '1'() { return 0; } };
|
||||
~~~
|
||||
!!! An object literal cannot have property and accessor with the same name.
|
||||
~~~
|
||||
!!! Duplicate identifier ''1''.
|
||||
var f12 = { 0: 0, get 0() { return 0; } };
|
||||
~
|
||||
!!! An object literal cannot have property and accessor with the same name.
|
||||
~
|
||||
!!! Duplicate identifier '0'.
|
||||
var f13 = { 0: 0, get 0() { return 0; } };
|
||||
~
|
||||
!!! An object literal cannot have property and accessor with the same name.
|
||||
~
|
||||
!!! Duplicate identifier '0'.
|
||||
var f14 = { 0: 0, get 0x0() { return 0; } };
|
||||
~~~
|
||||
!!! An object literal cannot have property and accessor with the same name.
|
||||
~~~
|
||||
!!! Duplicate identifier '0x0'.
|
||||
var f14 = { 0: 0, get 000() { return 0; } };
|
||||
~~~
|
||||
!!! An object literal cannot have property and accessor with the same name.
|
||||
~~~
|
||||
!!! Duplicate identifier '000'.
|
||||
var f15 = { "100": 0, get 1e2() { return 0; } };
|
||||
~~~
|
||||
!!! An object literal cannot have property and accessor with the same name.
|
||||
~~~
|
||||
!!! Duplicate identifier '1e2'.
|
||||
var f16 = { 0x20: 0, get 3.2e1() { return 0; } };
|
||||
~~~~~
|
||||
!!! An object literal cannot have property and accessor with the same name.
|
||||
~~~~~
|
||||
!!! Duplicate identifier '3.2e1'.
|
||||
var f17 = { a: 0, get b() { return 1; }, get a() { return 0; } };
|
||||
~
|
||||
!!! An object literal cannot have property and accessor with the same name.
|
||||
~
|
||||
!!! Duplicate identifier 'a'.
|
||||
|
||||
// Get and set accessor with mismatched type annotations
|
||||
|
|
|
@ -1,135 +0,0 @@
|
|||
//// [objectLiteralErrors.ts]
|
||||
|
||||
// Multiple properties with the same name
|
||||
var e1 = { a: 0, a: 0 };
|
||||
var e2 = { a: '', a: '' };
|
||||
var e3 = { a: 0, a: '' };
|
||||
var e4 = { a: true, a: false };
|
||||
var e5 = { a: {}, a: {} };
|
||||
var e6 = { a: 0, 'a': 0 };
|
||||
var e7 = { 'a': 0, a: 0 };
|
||||
var e8 = { 'a': 0, "a": 0 };
|
||||
var e9 = { 'a': 0, 'a': 0 };
|
||||
var e10 = { "a": 0, 'a': 0 };
|
||||
var e11 = { 1.0: 0, '1': 0 };
|
||||
var e12 = { 0: 0, 0: 0 };
|
||||
var e13 = { 0: 0, 0: 0 };
|
||||
var e14 = { 0: 0, 0x0: 0 };
|
||||
var e14 = { 0: 0, 000: 0 };
|
||||
var e15 = { "100": 0, 1e2: 0 };
|
||||
var e16 = { 0x20: 0, 3.2e1: 0 };
|
||||
var e17 = { a: 0, b: 1, a: 0 };
|
||||
|
||||
// Accessor and property with the same name
|
||||
var f1 = { a: 0, get a() { return 0; } };
|
||||
var f2 = { a: '', get a() { return ''; } };
|
||||
var f3 = { a: 0, get a() { return ''; } };
|
||||
var f4 = { a: true, get a() { return false; } };
|
||||
var f5 = { a: {}, get a() { return {}; } };
|
||||
var f6 = { a: 0, get 'a'() { return 0; } };
|
||||
var f7 = { 'a': 0, get a() { return 0; } };
|
||||
var f8 = { 'a': 0, get "a"() { return 0; } };
|
||||
var f9 = { 'a': 0, get 'a'() { return 0; } };
|
||||
var f10 = { "a": 0, get 'a'() { return 0; } };
|
||||
var f11 = { 1.0: 0, get '1'() { return 0; } };
|
||||
var f12 = { 0: 0, get 0() { return 0; } };
|
||||
var f13 = { 0: 0, get 0() { return 0; } };
|
||||
var f14 = { 0: 0, get 0x0() { return 0; } };
|
||||
var f14 = { 0: 0, get 000() { return 0; } };
|
||||
var f15 = { "100": 0, get 1e2() { return 0; } };
|
||||
var f16 = { 0x20: 0, get 3.2e1() { return 0; } };
|
||||
var f17 = { a: 0, get b() { return 1; }, get a() { return 0; } };
|
||||
|
||||
// Get and set accessor with mismatched type annotations
|
||||
var g1 = { get a(): number { return 4; }, set a(n: string) { } };
|
||||
var g2 = { get a() { return 4; }, set a(n: string) { } };
|
||||
var g3 = { get a(): number { return undefined; }, set a(n: string) { } };
|
||||
|
||||
|
||||
//// [objectLiteralErrors.js]
|
||||
var e1 = { a: 0, a: 0 };
|
||||
var e2 = { a: '', a: '' };
|
||||
var e3 = { a: 0, a: '' };
|
||||
var e4 = { a: true, a: false };
|
||||
var e5 = { a: {}, a: {} };
|
||||
var e6 = { a: 0, 'a': 0 };
|
||||
var e7 = { 'a': 0, a: 0 };
|
||||
var e8 = { 'a': 0, "a": 0 };
|
||||
var e9 = { 'a': 0, 'a': 0 };
|
||||
var e10 = { "a": 0, 'a': 0 };
|
||||
var e11 = { 1.0: 0, '1': 0 };
|
||||
var e12 = { 0: 0, 0: 0 };
|
||||
var e13 = { 0: 0, 0: 0 };
|
||||
var e14 = { 0: 0, 0x0: 0 };
|
||||
var e14 = { 0: 0, 000: 0 };
|
||||
var e15 = { "100": 0, 1e2: 0 };
|
||||
var e16 = { 0x20: 0, 3.2e1: 0 };
|
||||
var e17 = { a: 0, b: 1, a: 0 };
|
||||
var f1 = { a: 0, get a() {
|
||||
return 0;
|
||||
} };
|
||||
var f2 = { a: '', get a() {
|
||||
return '';
|
||||
} };
|
||||
var f3 = { a: 0, get a() {
|
||||
return '';
|
||||
} };
|
||||
var f4 = { a: true, get a() {
|
||||
return false;
|
||||
} };
|
||||
var f5 = { a: {}, get a() {
|
||||
return {};
|
||||
} };
|
||||
var f6 = { a: 0, get 'a'() {
|
||||
return 0;
|
||||
} };
|
||||
var f7 = { 'a': 0, get a() {
|
||||
return 0;
|
||||
} };
|
||||
var f8 = { 'a': 0, get "a"() {
|
||||
return 0;
|
||||
} };
|
||||
var f9 = { 'a': 0, get 'a'() {
|
||||
return 0;
|
||||
} };
|
||||
var f10 = { "a": 0, get 'a'() {
|
||||
return 0;
|
||||
} };
|
||||
var f11 = { 1.0: 0, get '1'() {
|
||||
return 0;
|
||||
} };
|
||||
var f12 = { 0: 0, get 0() {
|
||||
return 0;
|
||||
} };
|
||||
var f13 = { 0: 0, get 0() {
|
||||
return 0;
|
||||
} };
|
||||
var f14 = { 0: 0, get 0x0() {
|
||||
return 0;
|
||||
} };
|
||||
var f14 = { 0: 0, get 000() {
|
||||
return 0;
|
||||
} };
|
||||
var f15 = { "100": 0, get 1e2() {
|
||||
return 0;
|
||||
} };
|
||||
var f16 = { 0x20: 0, get 3.2e1() {
|
||||
return 0;
|
||||
} };
|
||||
var f17 = { a: 0, get b() {
|
||||
return 1;
|
||||
}, get a() {
|
||||
return 0;
|
||||
} };
|
||||
var g1 = { get a() {
|
||||
return 4;
|
||||
}, set a(n) {
|
||||
} };
|
||||
var g2 = { get a() {
|
||||
return 4;
|
||||
}, set a(n) {
|
||||
} };
|
||||
var g3 = { get a() {
|
||||
return undefined;
|
||||
}, set a(n) {
|
||||
} };
|
|
@ -2,7 +2,7 @@
|
|||
var f: (x: 'hi') => number = ('hi') => { return 1; };
|
||||
~~
|
||||
!!! ';' expected.
|
||||
~~~~~~
|
||||
!!! A 'return' statement can only be used within a function body.
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
||||
~~~~~~~~~
|
||||
!!! 'return' statement has no containing function.
|
||||
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
|
@ -1,4 +1,4 @@
|
|||
==== tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts (1 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts (4 errors) ====
|
||||
/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
/// Ecma International makes this code available under the terms and conditions set
|
||||
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
|
@ -18,4 +18,10 @@
|
|||
~~~~~~~~~~~~~
|
||||
!!! Cannot find name 'NotEarlyError'.
|
||||
var public = 1;
|
||||
~~~~~~
|
||||
!!! Variable declaration expected.
|
||||
~
|
||||
!!! Variable declaration expected.
|
||||
~
|
||||
!!! Variable declaration expected.
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
//// [parser10.1.1-8gs.ts]
|
||||
/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
/// Ecma International makes this code available under the terms and conditions set
|
||||
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
|
||||
/**
|
||||
* @path ch10/10.1/10.1.1/10.1.1-8gs.js
|
||||
* @description Strict Mode - Use Strict Directive Prologue is ''use strict';' which appears twice in the code
|
||||
* @noStrict
|
||||
* @negative ^((?!NotEarlyError).)*$
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
"use strict";
|
||||
throw NotEarlyError;
|
||||
var public = 1;
|
||||
|
||||
|
||||
//// [parser10.1.1-8gs.js]
|
||||
"use strict";
|
||||
"use strict";
|
||||
throw NotEarlyError;
|
||||
var public = 1;
|
|
@ -1,4 +1,4 @@
|
|||
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser566700.ts (1 errors) ====
|
||||
var v = ()({});
|
||||
~
|
||||
!!! '=>' expected.
|
||||
~
|
||||
!!! Expression expected.
|
9
tests/baselines/reference/parser642331_1.errors.txt
Normal file
9
tests/baselines/reference/parser642331_1.errors.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser642331_1.ts (1 errors) ====
|
||||
"use strict";
|
||||
|
||||
class test {
|
||||
constructor (static) { }
|
||||
~~~~~~
|
||||
!!! Identifier expected.
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
//// [parser642331_1.ts]
|
||||
"use strict";
|
||||
|
||||
class test {
|
||||
constructor (static) { }
|
||||
}
|
||||
|
||||
|
||||
//// [parser642331_1.js]
|
||||
"use strict";
|
||||
var test = (function () {
|
||||
function test(static) {
|
||||
}
|
||||
return test;
|
||||
})();
|
|
@ -1,8 +1,6 @@
|
|||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEmptyParenthesizedExpression1.ts (2 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEmptyParenthesizedExpression1.ts (1 errors) ====
|
||||
function getObj() {
|
||||
().toString();
|
||||
~
|
||||
!!! '=>' expected.
|
||||
~~~~~~~~
|
||||
!!! Cannot find name 'toString'.
|
||||
~
|
||||
!!! Expression expected.
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Expressions/parserErrorRecovery_Expression1.ts (1 errors) ====
|
||||
var v = ()({});
|
||||
~
|
||||
!!! '=>' expected.
|
||||
~
|
||||
!!! Expression expected.
|
|
@ -1,13 +1,13 @@
|
|||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ModuleElements/parserErrorRecovery_ModuleElement1.ts (4 errors) ====
|
||||
return foo;
|
||||
~~~~~~~~~~~
|
||||
!!! 'return' statement has no containing function.
|
||||
~~~~~~
|
||||
!!! A 'return' statement can only be used within a function body.
|
||||
}
|
||||
~
|
||||
!!! Declaration or statement expected.
|
||||
return bar;
|
||||
~~~~~~~~~~~
|
||||
!!! 'return' statement has no containing function.
|
||||
~~~~~~
|
||||
!!! A 'return' statement can only be used within a function body.
|
||||
}
|
||||
~
|
||||
!!! Declaration or statement expected.
|
|
@ -1,10 +1,6 @@
|
|||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList5.ts (4 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList5.ts (2 errors) ====
|
||||
(a:number => { }
|
||||
~
|
||||
!!! ')' expected.
|
||||
~~
|
||||
!!! ';' expected.
|
||||
~
|
||||
!!! Cannot find name 'a'.
|
||||
~~~~~~
|
||||
!!! Cannot find name 'number'.
|
||||
!!! ',' expected.
|
||||
~
|
||||
!!! ')' expected.
|
|
@ -1,5 +1,7 @@
|
|||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/VariableLists/parserErrorRecovery_VariableList1.ts (1 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/VariableLists/parserErrorRecovery_VariableList1.ts (2 errors) ====
|
||||
var a,
|
||||
~
|
||||
!!! Trailing comma not allowed.
|
||||
return;
|
||||
return;
|
||||
~~~~~~
|
||||
!!! A 'return' statement can only be used within a function body.
|
|
@ -4,6 +4,6 @@
|
|||
!!! Cannot find name 'a'.
|
||||
{
|
||||
return true;
|
||||
~~~~~~~~~~~~
|
||||
!!! 'return' statement has no containing function.
|
||||
~~~~~~
|
||||
!!! A 'return' statement can only be used within a function body.
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
//// [parserNotRegex1.ts]
|
||||
if (a.indexOf(-(4/3))) // We should not get a regex here becuase of the / in the comment.
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//// [parserNotRegex1.js]
|
||||
if (a.indexOf(-(4 / 3))) {
|
||||
return true;
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserPublicBreak1.ts (1 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserPublicBreak1.ts (2 errors) ====
|
||||
public break;
|
||||
~~~~~~
|
||||
!!! Declaration or statement expected.
|
||||
~~~~~~
|
||||
!!! A 'break' statement can only be used within an enclosing iteration or switch statement.
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
==== tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpression1.ts (1 errors) ====
|
||||
return /(#?-?\d*\.\d\w*%?)|(@?#?[\w-?]+%?)/g;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! 'return' statement has no containing function.
|
||||
~~~~~~
|
||||
!!! A 'return' statement can only be used within a function body.
|
|
@ -1,5 +0,0 @@
|
|||
//// [parserRegularExpression1.ts]
|
||||
return /(#?-?\d*\.\d\w*%?)|(@?#?[\w-?]+%?)/g;
|
||||
|
||||
//// [parserRegularExpression1.js]
|
||||
return /(#?-?\d*\.\d\w*%?)|(@?#?[\w-?]+%?)/g;
|
|
@ -0,0 +1,4 @@
|
|||
==== tests/cases/conformance/parser/ecmascript5/Statements/ReturnStatements/parserReturnStatement1.ts (1 errors) ====
|
||||
return;
|
||||
~~~~~~
|
||||
!!! A 'return' statement can only be used within a function body.
|
|
@ -1,5 +0,0 @@
|
|||
//// [parserReturnStatement1.ts]
|
||||
return;
|
||||
|
||||
//// [parserReturnStatement1.js]
|
||||
return;
|
|
@ -0,0 +1,6 @@
|
|||
==== tests/cases/conformance/parser/ecmascript5/Statements/ReturnStatements/parserReturnStatement2.ts (1 errors) ====
|
||||
{
|
||||
return;
|
||||
~~~~~~
|
||||
!!! A 'return' statement can only be used within a function body.
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
//// [parserReturnStatement2.ts]
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//// [parserReturnStatement2.js]
|
||||
{
|
||||
return;
|
||||
}
|
|
@ -1,22 +1,13 @@
|
|||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserStatementIsNotAMemberVariableDeclaration1.ts (1 errors) ====
|
||||
return {
|
||||
~~~~~~~~
|
||||
|
||||
~~~~~~
|
||||
!!! A 'return' statement can only be used within a function body.
|
||||
|
||||
"set": function (key, value) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
// 'private' should not be considered a member variable here.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
private[key] = value;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
}
|
||||
~~~
|
||||
|
||||
|
||||
};
|
||||
~~
|
||||
!!! 'return' statement has no containing function.
|
||||
};
|
|
@ -1,18 +0,0 @@
|
|||
//// [parserStatementIsNotAMemberVariableDeclaration1.ts]
|
||||
return {
|
||||
|
||||
"set": function (key, value) {
|
||||
|
||||
// 'private' should not be considered a member variable here.
|
||||
private[key] = value;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//// [parserStatementIsNotAMemberVariableDeclaration1.js]
|
||||
return {
|
||||
"set": function (key, value) {
|
||||
private[key] = value;
|
||||
}
|
||||
};
|
6
tests/baselines/reference/parserStrictMode10.errors.txt
Normal file
6
tests/baselines/reference/parserStrictMode10.errors.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode10.ts (1 errors) ====
|
||||
"use strict";
|
||||
function f(eval) {
|
||||
~~~~
|
||||
!!! Invalid use of 'eval' in strict mode.
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
//// [parserStrictMode10.ts]
|
||||
"use strict";
|
||||
function f(eval) {
|
||||
}
|
||||
|
||||
//// [parserStrictMode10.js]
|
||||
"use strict";
|
||||
function f(eval) {
|
||||
}
|
6
tests/baselines/reference/parserStrictMode11.errors.txt
Normal file
6
tests/baselines/reference/parserStrictMode11.errors.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode11.ts (1 errors) ====
|
||||
"use strict";
|
||||
var v = function f(eval) {
|
||||
~~~~
|
||||
!!! Invalid use of 'eval' in strict mode.
|
||||
};
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue