Skip to content

Commit

Permalink
Merge pull request #215 from Microsoft/labelledStatements
Browse files Browse the repository at this point in the history
Parser analysis and errors for labelled statements, break, continue, return
  • Loading branch information
JsonFreeman committed Jul 25, 2014
2 parents 98e65f2 + 86007cc commit cb98c5a
Show file tree
Hide file tree
Showing 133 changed files with 879 additions and 1,267 deletions.
3 changes: 0 additions & 3 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5276,9 +5276,6 @@ module ts {
}
}
}
else {
error(node, Diagnostics.return_statement_has_no_containing_function);
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
17 changes: 9 additions & 8 deletions src/compiler/diagnosticInformationMap.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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." },
Expand Down Expand Up @@ -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}'." },
Expand Down
32 changes: 18 additions & 14 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cb98c5a

Please sign in to comment.