From ac54fbfa462d930600da96933d6bb31df53d4a49 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 30 Oct 2014 23:05:18 -0700 Subject: [PATCH] set 'earlyError' bit to 'non-constant expression in constant enum initializer' error --- .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 3 +- tests/baselines/reference/constEnumErrors.js | 58 ------------------- 3 files changed, 3 insertions(+), 60 deletions(-) delete mode 100644 tests/baselines/reference/constEnumErrors.js diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index c37cf3661ee..ca724e5b6e6 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -351,7 +351,7 @@ module ts { Exported_type_alias_0_has_or_is_using_name_1_from_private_module_2: { code: 4080, category: DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using name '{1}' from private module '{2}'." }, Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using private name '{1}'." }, Enum_declarations_must_all_be_const_or_non_const: { code: 4082, category: DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." }, - In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 4083, category: DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression." }, + In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 4083, category: DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression.", isEarly: true }, const_enums_can_only_be_used_in_property_access_Slashindex_access_expressions_and_as_right_hand_side_in_import_declarations_Slashexport_assignments: { code: 4084, category: DiagnosticCategory.Error, key: "'const' enums can only be used in property access/index access expressions and as right hand side in import declarations/export assignments." }, Index_expression_arguments_in_const_enums_must_be_of_type_string: { code: 4085, category: DiagnosticCategory.Error, key: "Index expression arguments in 'const' enums must be of type 'string'." }, const_enum_member_initializer_was_evaluated_to_a_non_finite_number: { code: 4086, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite number." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b2a372f3794..6649f470de3 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1407,7 +1407,8 @@ }, "In 'const' enum declarations member initializer must be constant expression.": { "category": "Error", - "code": 4083 + "code": 4083, + "isEarly": true }, "'const' enums can only be used in property access/index access expressions and as right hand side in import declarations/export assignments.": { "category": "Error", diff --git a/tests/baselines/reference/constEnumErrors.js b/tests/baselines/reference/constEnumErrors.js deleted file mode 100644 index 4afd98982f0..00000000000 --- a/tests/baselines/reference/constEnumErrors.js +++ /dev/null @@ -1,58 +0,0 @@ -//// [constEnumErrors.ts] -const enum E { - A -} - -module E { - var x = 1; -} - -const enum E1 { - // illegal case - // forward reference to the element of the same enum - X = Y, - // forward reference to the element of the same enum - Y = E1.Z, - Y1 = E1["Z"] -} - -const enum E2 { - A -} - -var y0 = E2[1] -var name = "A"; -var y1 = E2[name]; - -var x = E2; -var y = [E2]; - -function foo(t: any): void { -} - -foo(E2); - -const enum NaNOrInfinity { - A = 9007199254740992, - B = A * A, - C = B * B, - D = C * C, - E = D * D, - F = E * E, // overflow - G = 1 / 0, // overflow - H = 0 / 0 // NaN -} - -//// [constEnumErrors.js] -var E; -(function (E) { - var x = 1; -})(E || (E = {})); -var y0 = E2[1]; -var name = "A"; -var y1 = E2[name]; -var x = E2; -var y = [E2]; -function foo(t) { -} -foo(E2);