mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-12 11:50:54 -06:00
Merge pull request #215 from Microsoft/labelledStatements
Parser analysis and errors for labelled statements, break, continue, return
This commit is contained in:
commit
cb98c5aa17
@ -5276,9 +5276,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,19 +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." },
|
||||
An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1114, 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: 1115, 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: 1116, category: DiagnosticCategory.Error, key: "An object literal cannot have property and accessor with the same name." },
|
||||
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." },
|
||||
@ -272,7 +274,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,18 +384,30 @@
|
||||
"category": "Error",
|
||||
"code": 1113
|
||||
},
|
||||
"An object literal cannot have multiple properties with the same name in strict mode.": {
|
||||
"Duplicate label '{0}'": {
|
||||
"category": "Error",
|
||||
"code": 1114
|
||||
},
|
||||
"An object literal cannot have multiple get/set accessors with the same name.": {
|
||||
"A 'continue' statement can only jump to a label of an enclosing iteration statement.": {
|
||||
"category": "Error",
|
||||
"code": 1115
|
||||
},
|
||||
"An object literal cannot have property and accessor with the same name.": {
|
||||
"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
|
||||
@ -1106,10 +1114,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
|
||||
|
||||
@ -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);
|
||||
@ -389,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;
|
||||
@ -403,6 +423,113 @@ module ts {
|
||||
|
||||
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) {
|
||||
@ -2058,8 +2185,27 @@ module ts {
|
||||
}
|
||||
|
||||
function parseBody(ignoreMissingOpenBrace: boolean): Block {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -2083,7 +2229,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();
|
||||
@ -2103,7 +2254,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);
|
||||
}
|
||||
|
||||
@ -2122,53 +2278,142 @@ 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);
|
||||
}
|
||||
|
||||
@ -2218,7 +2463,12 @@ module ts {
|
||||
node.expression = parseExpression();
|
||||
parseExpected(SyntaxKind.CloseParenToken);
|
||||
parseExpected(SyntaxKind.OpenBraceToken);
|
||||
|
||||
var saveInSwitchStatement = inSwitchStatement;
|
||||
inSwitchStatement = ControlBlockContext.Nested;
|
||||
node.clauses = parseList(ParsingContext.SwitchClauses, /*checkForStrictMode*/ false, parseCaseOrDefaultClause);
|
||||
inSwitchStatement = saveInSwitchStatement;
|
||||
|
||||
parseExpected(SyntaxKind.CloseBraceToken);
|
||||
|
||||
// Error on duplicate 'default' clauses.
|
||||
@ -2301,11 +2551,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);
|
||||
}
|
||||
|
||||
@ -2395,7 +2668,7 @@ module ts {
|
||||
case SyntaxKind.DebuggerKeyword:
|
||||
return parseDebuggerStatement();
|
||||
default:
|
||||
if (isIdentifier() && lookAhead(() => nextToken() === SyntaxKind.ColonToken)) {
|
||||
if (isLabel()) {
|
||||
return parseLabelledStatement();
|
||||
}
|
||||
return parseExpressionStatement();
|
||||
|
||||
@ -404,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 {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -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) {
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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,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,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;
|
||||
}
|
||||
};
|
||||
@ -1,5 +1,7 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement2.ts (1 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement2.ts (2 errors) ====
|
||||
with (1)
|
||||
~
|
||||
!!! All symbols within a 'with' block will be resolved to 'any'.
|
||||
return;
|
||||
return;
|
||||
~~~~~~
|
||||
!!! A 'return' statement can only be used within a function body.
|
||||
@ -1,7 +0,0 @@
|
||||
//// [parserWithStatement2.ts]
|
||||
with (1)
|
||||
return;
|
||||
|
||||
//// [parserWithStatement2.js]
|
||||
with (1)
|
||||
return;
|
||||
@ -0,0 +1,4 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakNotInIterationOrSwitchStatement1.ts (1 errors) ====
|
||||
break;
|
||||
~~~~~~
|
||||
!!! A 'break' statement can only be used within an enclosing iteration or switch statement.
|
||||
@ -1,5 +0,0 @@
|
||||
//// [parser_breakNotInIterationOrSwitchStatement1.ts]
|
||||
break;
|
||||
|
||||
//// [parser_breakNotInIterationOrSwitchStatement1.js]
|
||||
break;
|
||||
@ -0,0 +1,8 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakNotInIterationOrSwitchStatement2.ts (1 errors) ====
|
||||
while (true) {
|
||||
function f() {
|
||||
break;
|
||||
~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
//// [parser_breakNotInIterationOrSwitchStatement2.ts]
|
||||
while (true) {
|
||||
function f() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//// [parser_breakNotInIterationOrSwitchStatement2.js]
|
||||
while (true) {
|
||||
function f() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
11
tests/baselines/reference/parser_breakTarget5.errors.txt
Normal file
11
tests/baselines/reference/parser_breakTarget5.errors.txt
Normal file
@ -0,0 +1,11 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget5.ts (1 errors) ====
|
||||
target:
|
||||
while (true) {
|
||||
function f() {
|
||||
while (true) {
|
||||
break target;
|
||||
~~~~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
//// [parser_breakTarget5.ts]
|
||||
target:
|
||||
while (true) {
|
||||
function f() {
|
||||
while (true) {
|
||||
break target;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [parser_breakTarget5.js]
|
||||
target: while (true) {
|
||||
function f() {
|
||||
while (true) {
|
||||
break target;
|
||||
}
|
||||
}
|
||||
}
|
||||
6
tests/baselines/reference/parser_breakTarget6.errors.txt
Normal file
6
tests/baselines/reference/parser_breakTarget6.errors.txt
Normal file
@ -0,0 +1,6 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget6.ts (1 errors) ====
|
||||
while (true) {
|
||||
break target;
|
||||
~~~~~~~~~~~~~
|
||||
!!! A 'break' statement can only jump to a label of an enclosing statement.
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
//// [parser_breakTarget6.ts]
|
||||
while (true) {
|
||||
break target;
|
||||
}
|
||||
|
||||
//// [parser_breakTarget6.js]
|
||||
while (true) {
|
||||
break target;
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueNotInIterationStatement1.ts (1 errors) ====
|
||||
continue;
|
||||
~~~~~~~~~
|
||||
!!! A 'continue' statement can only be used within an enclosing iteration statement.
|
||||
@ -1,5 +0,0 @@
|
||||
//// [parser_continueNotInIterationStatement1.ts]
|
||||
continue;
|
||||
|
||||
//// [parser_continueNotInIterationStatement1.js]
|
||||
continue;
|
||||
@ -0,0 +1,8 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueNotInIterationStatement2.ts (1 errors) ====
|
||||
while (true) {
|
||||
function f() {
|
||||
continue;
|
||||
~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
//// [parser_continueNotInIterationStatement2.ts]
|
||||
while (true) {
|
||||
function f() {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//// [parser_continueNotInIterationStatement2.js]
|
||||
while (true) {
|
||||
function f() {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueNotInIterationStatement3.ts (1 errors) ====
|
||||
switch (0) {
|
||||
default:
|
||||
continue;
|
||||
~~~~~~~~~
|
||||
!!! A 'continue' statement can only be used within an enclosing iteration statement.
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
//// [parser_continueNotInIterationStatement3.ts]
|
||||
switch (0) {
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
//// [parser_continueNotInIterationStatement3.js]
|
||||
switch (0) {
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueNotInIterationStatement4.ts (1 errors) ====
|
||||
TWO:
|
||||
while (true){
|
||||
var x = () => {
|
||||
continue TWO;
|
||||
~~~~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
//// [parser_continueNotInIterationStatement4.ts]
|
||||
TWO:
|
||||
while (true){
|
||||
var x = () => {
|
||||
continue TWO;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [parser_continueNotInIterationStatement4.js]
|
||||
TWO: while (true) {
|
||||
var x = function () {
|
||||
continue TWO;
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget1.ts (1 errors) ====
|
||||
target:
|
||||
continue target;
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! A 'continue' statement can only jump to a label of an enclosing iteration statement.
|
||||
@ -1,6 +0,0 @@
|
||||
//// [parser_continueTarget1.ts]
|
||||
target:
|
||||
continue target;
|
||||
|
||||
//// [parser_continueTarget1.js]
|
||||
target: continue target;
|
||||
11
tests/baselines/reference/parser_continueTarget5.errors.txt
Normal file
11
tests/baselines/reference/parser_continueTarget5.errors.txt
Normal file
@ -0,0 +1,11 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget5.ts (1 errors) ====
|
||||
target:
|
||||
while (true) {
|
||||
function f() {
|
||||
while (true) {
|
||||
continue target;
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! Jump target cannot cross function boundary.
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
//// [parser_continueTarget5.ts]
|
||||
target:
|
||||
while (true) {
|
||||
function f() {
|
||||
while (true) {
|
||||
continue target;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [parser_continueTarget5.js]
|
||||
target: while (true) {
|
||||
function f() {
|
||||
while (true) {
|
||||
continue target;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget6.ts (1 errors) ====
|
||||
while (true) {
|
||||
continue target;
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! A 'continue' statement can only jump to a label of an enclosing iteration statement.
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
//// [parser_continueTarget6.ts]
|
||||
while (true) {
|
||||
continue target;
|
||||
}
|
||||
|
||||
//// [parser_continueTarget6.js]
|
||||
while (true) {
|
||||
continue target;
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel1.ts (1 errors) ====
|
||||
target:
|
||||
target:
|
||||
~~~~~~
|
||||
!!! Duplicate label 'target'
|
||||
while (true) {
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
//// [parser_duplicateLabel1.ts]
|
||||
target:
|
||||
target:
|
||||
while (true) {
|
||||
}
|
||||
|
||||
//// [parser_duplicateLabel1.js]
|
||||
target: target: while (true) {
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel2.ts (1 errors) ====
|
||||
target:
|
||||
while (true) {
|
||||
target:
|
||||
~~~~~~
|
||||
!!! Duplicate label 'target'
|
||||
while (true) {
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
//// [parser_duplicateLabel2.ts]
|
||||
target:
|
||||
while (true) {
|
||||
target:
|
||||
while (true) {
|
||||
}
|
||||
}
|
||||
|
||||
//// [parser_duplicateLabel2.js]
|
||||
target: while (true) {
|
||||
target: while (true) {
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user