Back out "Add compiler only attributes to disable readonly checking and coeffect...
[hiphop-php.git] / hphp / hack / src / parser / syntax_error.rs
blob5d63e7f7f38532e77e071a5ba3e74b715f2b3b14
1 #![allow(non_upper_case_globals)]
2 // Copyright (c) 2019, Facebook, Inc.
3 // All rights reserved.
4 //
5 // This source code is licensed under the MIT license found in the
6 // LICENSE file in the "hack" directory of this source tree.
7 //
9 use crate::token_kind::TokenKind;
10 use ocamlrep_derive::{FromOcamlRep, ToOcamlRep};
11 use std::{borrow::Cow, cmp::Ordering};
13 use naming_special_names_rust::user_attributes as ua;
15 // many errors are static strings, but not all of them
16 pub type Error = Cow<'static, str>;
18 #[derive(Debug, Clone, FromOcamlRep, ToOcamlRep, PartialEq, Eq)]
19 pub enum ErrorType {
20     ParseError,
21     RuntimeError,
24 #[derive(Debug, Clone, FromOcamlRep, ToOcamlRep, PartialEq, Eq)]
25 pub struct SyntaxError {
26     pub child: Option<Box<SyntaxError>>,
27     pub start_offset: usize,
28     pub end_offset: usize,
29     pub error_type: ErrorType,
30     pub message: Error,
33 impl SyntaxError {
34     pub fn make_with_child_and_type(
35         child: Option<SyntaxError>,
36         start_offset: usize,
37         end_offset: usize,
38         error_type: ErrorType,
39         message: Error,
40     ) -> Self {
41         Self {
42             child: child.map(|x| Box::new(x)),
43             start_offset,
44             end_offset,
45             error_type,
46             message,
47         }
48     }
50     pub fn make(start_offset: usize, end_offset: usize, message: Error) -> Self {
51         Self::make_with_child_and_type(
52             None,
53             start_offset,
54             end_offset,
55             ErrorType::ParseError,
56             message,
57         )
58     }
60     pub fn compare_offset(e1: &Self, e2: &Self) -> Ordering {
61         (e1.start_offset, e1.end_offset).cmp(&(e2.start_offset, e2.end_offset))
62     }
64     pub fn equal_offset(e1: &Self, e2: &Self) -> bool {
65         Self::compare_offset(e1, e2) == Ordering::Equal
66     }
68     pub fn weak_equal(e1: &Self, e2: &Self) -> bool {
69         e1.start_offset == e2.start_offset
70             && e1.end_offset == e2.end_offset
71             && e1.message == e2.message
72     }
75 // Lexical errors
76 pub const error0001: Error = Cow::Borrowed("A hexadecimal literal needs at least one digit.");
77 pub const error0002: Error = Cow::Borrowed("A binary literal needs at least one digit.");
78 pub const error0003: Error = Cow::Borrowed(concat!(
79     "A floating point literal with an exponent needs at least ",
80     "one digit in the exponent."
81 ));
82 pub const error0006: Error = Cow::Borrowed("This character is invalid.");
83 pub const error0007: Error = Cow::Borrowed("This delimited comment is not terminated.");
84 pub const error0008: Error = Cow::Borrowed("A name is expected here.");
85 pub const error0010: Error = Cow::Borrowed("A single quote is expected here.");
86 pub const error0011: Error = Cow::Borrowed("A newline is expected here.");
87 pub const error0012: Error = Cow::Borrowed("This string literal is not terminated.");
88 pub const error0013: Error = Cow::Borrowed("This XHP body is not terminated.");
89 pub const error0014: Error = Cow::Borrowed("This XHP comment is not terminated.");
91 // Syntactic errors
92 pub const error1001: Error = Cow::Borrowed("A .php file must begin with `<?hh`.");
93 pub const error1003: Error = Cow::Borrowed("The `function` keyword is expected here.");
94 pub const error1004: Error = Cow::Borrowed("A name is expected here.");
95 pub const error1006: Error = Cow::Borrowed("A right brace `}` is expected here.");
96 pub const error1007: Error = Cow::Borrowed("A type specifier is expected here.");
97 pub const error1008: Error = Cow::Borrowed("A variable name is expected here.");
98 pub const error1010: Error = Cow::Borrowed("A semicolon `;` is expected here.");
99 pub const error1011: Error = Cow::Borrowed("A right parenthesis `)` is expected here.");
100 pub const error1013: Error = Cow::Borrowed("A closing angle bracket `>` is expected here.");
101 pub const error1014: Error =
102     Cow::Borrowed("A closing angle bracket `>` or comma is expected here.");
103 pub const error1015: Error = Cow::Borrowed("An expression is expected here.");
104 pub const error1016: Error = Cow::Borrowed("An assignment is expected here.");
105 pub const error1017: Error = Cow::Borrowed("An XHP attribute value is expected here.");
106 pub const error1018: Error = Cow::Borrowed("The `while` keyword is expected here.");
107 pub const error1019: Error = Cow::Borrowed("A left parenthesis `(` is expected here.");
108 pub const error1020: Error = Cow::Borrowed("A colon `:` is expected here.");
109 pub const error1021: Error = Cow::Borrowed("An opening angle bracket `<` is expected here.");
110 // TODO: Remove this; redundant to 1009.
111 pub const error1022: Error =
112     Cow::Borrowed("A right parenthesis `)` or comma `,` is expected here.");
113 pub const error1023: Error = Cow::Borrowed("An `as` keyword is expected here.");
114 pub const error1025: Error = Cow::Borrowed("A shape field name is expected here.");
115 pub const error1026: Error = Cow::Borrowed("An opening square bracket `[` is expected here.");
116 pub const error1028: Error = Cow::Borrowed("An arrow `=>` is expected here.");
117 pub const error1029: Error = Cow::Borrowed("A closing double angle bracket `>>` is expected here.");
118 pub const error1031: Error =
119     Cow::Borrowed("A comma `,` or a closing square bracket `]` is expected here.");
120 pub const error1032: Error = Cow::Borrowed("A closing square bracket `]` is expected here.");
121 // TODO: Break this up according to classish type
122 pub const error1033: Error = Cow::Borrowed(concat!(
123     "A class member, method, type, trait usage, trait require, ",
124     "xhp attribute, xhp use, or xhp category is expected here."
126 pub const error1034: Error = Cow::Borrowed("A left brace `{` is expected here.");
127 pub const error1035: Error = Cow::Borrowed("The `class` keyword is expected here.");
128 pub const error1036: Error = Cow::Borrowed("An equals sign `=` is expected here.");
129 pub const error1037: Error = Cow::Borrowed("The `record` keyword is expected here.");
130 pub const error1038: Error = Cow::Borrowed("A semicolon `;` or a namespace body is expected here.");
131 pub const error1039: Error = Cow::Borrowed("A closing XHP tag is expected here.");
132 pub const error1041: Error = Cow::Borrowed("A function body or a semicolon `;` is expected here.");
133 pub const error1044: Error = Cow::Borrowed("A name or `__construct` keyword is expected here.");
134 pub const error1045: Error =
135     Cow::Borrowed("An `extends` or `implements` keyword is expected here.");
136 pub const error1046: Error = Cow::Borrowed("A lambda arrow `==>` is expected here.");
137 pub const error1047: Error = Cow::Borrowed("A scope resolution operator `::` is expected here.");
138 pub const error1048: Error = Cow::Borrowed("A name, variable name or `class` is expected here.");
139 pub const error1050: Error = Cow::Borrowed("A name or variable name is expected here.");
140 pub const error1051: Error =
141     Cow::Borrowed("The `required` or `lateinit` keyword is expected here.");
142 pub const error1052: Error =
143     Cow::Borrowed("An XHP category name beginning with a `%` is expected here.");
144 pub const error1053: Error = Cow::Borrowed("An XHP name or category name is expected here.");
145 pub const error1054: Error = Cow::Borrowed("A comma `,` is expected here.");
146 pub const error1055: Error = Cow::Borrowed(concat!(
147     "A fallthrough directive can only appear at the end of",
148     " a `switch` section."
150 // TODO(20052790): use the specific token's text in the message body.
151 pub const error1056: Error =
152     Cow::Borrowed("This token is not valid as part of a function declaration.");
153 pub fn error1057(text: &str) -> Error {
154     // TODO (kasper): T52404885: why does removing to_string() here segfaults
155     Cow::Owned(format!(
156         "Encountered unexpected token `{}`.",
157         text.to_string()
158     ))
160 pub fn uppercase_kw(text: &str) -> Error {
161     Cow::Owned(format!(
162         "Keyword `{}` must be written in lowercase",
163         text.to_string()
164     ))
166 pub fn error1058(received: &str, required: &str) -> Error {
167     Cow::Owned(format!(
168         "Encountered unexpected token `{}`. Did you mean `{}`?",
169         received.to_string(),
170         required.to_string()
171     ))
173 pub fn error1059(terminator: TokenKind) -> Error {
174     Cow::Owned(format!(
175         "An `{}` is required when using alternate block syntax.",
176         terminator.to_string().to_string(),
177     ))
179 pub fn error1060(extension: &str) -> Error {
180     let kind = if extension == "hack" {
181         "strict"
182     } else {
183         "partial"
184     };
185     Cow::Owned(format!(
186         "Leading markup and `<?hh` are not permitted in `.{}` files, which are always `{}`.",
187         extension.to_string(),
188         kind.to_string()
189     ))
191 pub const error1063: Error = Cow::Borrowed("Expected matching separator here.");
192 pub const error1064: Error = Cow::Borrowed("XHP children declarations are no longer supported.");
193 pub const error1065: Error = Cow::Borrowed("A backtick ``` is expected here.");
194 pub const error2001: Error = Cow::Borrowed("A type annotation is required in `strict` mode.");
195 pub const error2003: Error =
196     Cow::Borrowed("A `case` statement may only appear directly inside a `switch`.");
197 pub const error2004: Error =
198     Cow::Borrowed("A `default` statement may only appear directly inside a `switch`.");
199 pub const error2005: Error =
200     Cow::Borrowed("A `break` statement may only appear inside a `switch` or loop.");
201 pub const error2006: Error = Cow::Borrowed("A `continue` statement may only appear inside a loop.");
202 pub const error2007: Error =
203     Cow::Borrowed("A `try` statement requires a `catch` or a `finally` clause.");
204 pub const error2008: Error = Cow::Borrowed(concat!(
205     "The first statement inside a `switch` statement must ",
206     "be a `case` or `default` label statement."
208 pub fn error2009(class_name: &str, method_name: &str) -> Error {
209     Cow::Owned(format!(
210         "Constructor `{}::{}()` cannot be static",
211         class_name.to_string(),
212         method_name.to_string(),
213     ))
215 pub const error2010: Error = Cow::Borrowed(concat!(
216     "Parameters cannot have visibility modifiers (except in ",
217     "parameter lists of constructors)."
219 pub const error2014: Error = Cow::Borrowed("An abstract method cannot have a method body.");
220 pub const error2015: Error = Cow::Borrowed("A method must have a body or be marked `abstract`.");
222 pub fn error2016(class_name: &str, method_name: &str) -> Error {
223     Cow::Owned(format!(
224         "Cannot declare abstract method `{}::{}` `private`",
225         class_name.to_string(),
226         method_name.to_string(),
227     ))
229 pub const error2018: Error =
230     Cow::Borrowed("A constructor cannot have a non-`void` type annotation.");
231 pub fn error2019(class_name: &str, method_name: &str) -> Error {
232     Cow::Owned(format!(
233         "Cannot declare abstract method `{}::{}` `final`",
234         class_name.to_string(),
235         method_name.to_string(),
236     ))
238 pub const error2020: Error = Cow::Borrowed(concat!(
239     "Use of the `{}` subscript operator is deprecated; ",
240     " use `[]` instead."
242 pub const error2021: Error = Cow::Borrowed(concat!(
243     "A variadic parameter `...` may only appear at the end of ",
244     "a parameter list."
246 pub const error2023: Error =
247     Cow::Borrowed("Abstract constructors cannot have parameters with visibility modifiers");
248 pub const error2024: Error =
249     Cow::Borrowed("Traits or interfaces cannot have parameters with visibility modifiers");
250 pub const error2022: Error =
251     Cow::Borrowed("A variadic parameter `...` may not be followed by a comma.");
252 pub fn error2025(class_name: &str, prop_name: &str) -> Error {
253     Cow::Owned(format!(
254         "Cannot redeclare `{}::{}`",
255         class_name.to_string(),
256         prop_name.to_string(),
257     ))
259 pub const error2029: Error = Cow::Borrowed("Only traits and interfaces may use `require extends`.");
260 pub const error2030: Error = Cow::Borrowed("Only traits may use `require implements`.");
261 pub const error2032: Error = Cow::Borrowed("The array type is not allowed in `strict` mode.");
262 pub const error2033: Error = Cow::Borrowed(concat!(
263     "The splat operator `...` for unpacking variadic arguments ",
264     "may only appear at the **end** of an argument list."
266 pub const error2034: Error = Cow::Borrowed(concat!(
267     "A type alias declaration cannot both use `type` and have a ",
268     "constraint. Did you mean `newtype`?"
270 pub const error2035: Error = Cow::Borrowed("Only classes may implement interfaces.");
271 pub const error2036: Error = Cow::Borrowed(concat!(
272     "Only interfaces and classes may extend other interfaces and ",
273     "classes."
275 pub const error2037: Error = Cow::Borrowed("A class may extend at most **one** other class.");
276 pub fn error2038(constructor_name: &str) -> Error {
277     Cow::Owned(format!(
278         concat!(
279             "A constructor initializing an object must be passed a (possibly empty) ",
280             "list of arguments. Did you mean `new {}()`?",
281         ),
282         constructor_name.to_string(),
283     ))
285 pub const error2040: Error = Cow::Borrowed(concat!(
286     "Invalid use of `list(...)`. A list expression may only be ",
287     "used as the left side of a simple assignment, the value clause of a ",
288     "`foreach` loop, or a list item nested inside another list expression."
290 pub const error2041: Error = Cow::Borrowed(concat!(
291     "Unexpected method body: interfaces may contain only",
292     " method signatures, and **not** method implementations."
294 pub const error2042: Error = Cow::Borrowed("Only classes may be declared `abstract`.");
295 pub fn error2046(method_type: &str) -> Error {
296     Cow::Owned(format!(
297         "`async` cannot be used on {}. Use an `Awaitable<...>` return type instead.",
298         method_type.to_string(),
299     ))
302 pub const error2048: Error = Cow::Borrowed("Expected group `use` prefix to end with `\\`");
303 pub const error2049: Error =
304     Cow::Borrowed("A namespace `use` clause may not specify the kind here.");
305 pub const error2050: Error =
306     Cow::Borrowed("A concrete constant declaration must have an initializer.");
307 pub const error2052: Error = Cow::Borrowed(concat!(
308     "Cannot mix bracketed namespace declarations with ",
309     "unbracketed namespace declarations"
311 pub const error2053: Error = Cow::Borrowed(concat!(
312     "Use of `var` as synonym for `public` in declaration disallowed in Hack. ",
313     "Use `public` instead."
315 pub const error2054: Error = Cow::Borrowed(concat!(
316     "Method declarations require a visibility modifier ",
317     "such as `public`, `private` or `protected`."
319 pub const error2055: Error = Cow::Borrowed("At least one enumerated item is expected.");
320 pub const error2056: Error = Cow::Borrowed("First unbracketed namespace occurrence here");
321 pub const error2057: Error = Cow::Borrowed("First bracketed namespace occurrence here");
322 pub const invalid_shape_field_name: Error =
323     Cow::Borrowed("Shape field name must be a nonempty single-quoted string or a class constant");
324 pub const shape_field_int_like_string: Error =
325     Cow::Borrowed("Shape field name must not be an int-like string (i.e. \"123\")");
326 pub const error2061: Error = Cow::Borrowed(concat!(
327     "Non-static instance variables are not allowed in abstract ",
328     "final classes."
330 pub const error2062: Error =
331     Cow::Borrowed("Non-static methods are not allowed in `abstract final` classes.");
332 pub const error2063: Error = Cow::Borrowed("Expected integer or string literal.");
333 pub const error2065: Error =
334     Cow::Borrowed("A variadic parameter `...` must not have a default value.");
335 // This was typing error 4077.
336 pub const error2066: Error = Cow::Borrowed(concat!(
337     "A previous parameter has a default value. Remove all the ",
338     "default values for the preceding parameters, or add a default value to ",
339     "this one."
341 pub const error2068: Error = Cow::Borrowed("`hh` blocks and `php` blocks cannot be mixed.");
342 pub fn invalid_integer_digit(int_kind: ocaml_helper::IntKind) -> Error {
343     Cow::Owned(format!("Invalid digit for {} integers", int_kind))
345 pub const prefixed_invalid_string_kind: Error =
346     Cow::Borrowed("Only double-quoted strings may be prefixed.");
347 pub const illegal_interpolated_brace_with_embedded_dollar_expression: Error =
348     Cow::Borrowed(concat!(
349         "The only legal expressions inside a `{$...}`-expression embedded in a string are ",
350         "variables, function calls, subscript expressions, and member access expressions"
351     ));
352 pub const expected_dotdotdot: Error = Cow::Borrowed("`...` is expected here.");
353 pub const invalid_foreach_element: Error = Cow::Borrowed(
354     "An arrow `=>` or right parenthesis `)` \
355      is expected here.",
357 pub const inline_function_def: Error =
358     Cow::Borrowed("Inline function definitions are not supported in Hack");
359 pub const decl_outside_global_scope: Error =
360     Cow::Borrowed("Declarations are not supported outside global scope");
361 pub const type_keyword: Error = Cow::Borrowed("The `type` keyword is expected here.");
362 pub const expected_simple_offset_expression: Error =
363     Cow::Borrowed("A simple offset expression is expected here");
364 pub const expected_user_attribute: Error = Cow::Borrowed("A user attribute is expected here.");
365 pub const expected_as_or_insteadof: Error =
366     Cow::Borrowed("The `as` keyword or the `insteadof` keyword is expected here.");
367 pub const missing_double_quote: Error = /* error0010 analogue */
368     Cow::Borrowed("A double quote is expected here.");
369 pub const instanceof_disabled: Error = Cow::Borrowed(
370     "The `instanceof` operator is not supported in Hack; use the `is` operator or `is_a()`",
372 pub const abstract_instance_property: Error =
373     Cow::Borrowed("Instance property may not be abstract.");
374 pub const memoize_lsb_on_non_static: Error = Cow::Borrowed(
375     "`<<__MemoizeLSB>>` and `<<__PolicyShardedMemoizeLSB>>` can only be applied to static methods",
377 pub const memoize_lsb_on_non_method: Error = Cow::Borrowed(
378     "`<<__MemoizeLSB>>` and `<<__PolicyShardedMemoizeLSB>>` can only be applied to methods",
380 pub const expression_as_attribute_arguments: Error =
381     Cow::Borrowed("Attribute arguments must be literals");
382 pub const instanceof_invalid_scope_resolution: Error = Cow::Borrowed(concat!(
383     "A scope resolution `::` on the right side of an ",
384     "`instanceof` operator must start with a class name, `self`, `parent`, or `static`, and end with ",
385     "a variable",
387 pub const instanceof_memberselection_inside_scoperesolution: Error = Cow::Borrowed(concat!(
388     "A scope resolution `::` on the right ",
389     "side of an instanceof operator cannot contain a member selection `->`",
391 pub const instanceof_missing_subscript_index: Error = Cow::Borrowed(concat!(
392     "A subscript expression `[]` on the right side of an ",
393     "instanceof operator must have an index",
395 pub fn new_unknown_node(msg: &str) -> Error {
396     Cow::Owned(format!(
397         "`new` requires a class name or local variable, but got: `{}`",
398         msg.to_string(),
399     ))
401 pub const invalid_async_return_hint: Error =
402     Cow::Borrowed("`async` functions must have an `Awaitable` return type.");
403 pub const invalid_awaitable_arity: Error =
404     Cow::Borrowed("`Awaitable<_>` takes exactly one type argument.");
405 pub const invalid_await_use: Error = Cow::Borrowed("`await` cannot be used as an expression");
406 pub const toplevel_await_use: Error =
407     Cow::Borrowed("`await` cannot be used in a toplevel statement");
408 pub const invalid_constructor_method_call: Error = Cow::Borrowed(
409     "Method call following immediate constructor call requires parentheses around constructor call.",
411 pub const invalid_scope_resolution_qualifier: Error =
412     Cow::Borrowed("Only classnames and variables are allowed before `::`.");
413 pub const invalid_variable_name: Error = Cow::Borrowed(
414     "A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores",
416 pub const invalid_yield: Error =
417     Cow::Borrowed("`yield` can only appear as a statement or on the right of an assignment");
418 pub const invalid_class_in_collection_initializer: Error =
419     Cow::Borrowed("Cannot use collection initialization for non-collection class.");
420 pub const invalid_brace_kind_in_collection_initializer: Error = Cow::Borrowed(
421     "Initializers of `vec`, `dict` and `keyset` should use `[...]` instead of `{...}`.",
423 pub fn invalid_value_initializer(name: &str) -> Error {
424     Cow::Owned(format!(
425         "Cannot use value initializer for `{}`. It requires `key => value`.",
426         name.to_string(),
427     ))
429 pub fn invalid_key_value_initializer(name: &str) -> Error {
430     Cow::Owned(format!(
431         "Cannot use key value initializer for `{}`. It does not allow keys.",
432         name.to_string(),
433     ))
435 pub const nested_ternary: Error = Cow::Borrowed(
436     "Nested ternary expressions inside ternary expressions are ambiguous. Please add parentheses",
438 pub const alternate_control_flow: Error =
439     Cow::Borrowed("Alternate control flow syntax is not allowed in Hack files");
440 pub const execution_operator: Error =
441     Cow::Borrowed("The execution operator is not allowed in Hack files");
442 pub const non_re_prefix: Error = Cow::Borrowed("Only `re`-prefixed strings allowed.");
443 pub const collection_intrinsic_generic: Error =
444     Cow::Borrowed("Cannot initialize collection builtins with type parameters");
445 pub const collection_intrinsic_many_typeargs: Error =
446     Cow::Borrowed("Collection expression must have less than three type arguments");
447 pub const invalid_hack_mode: Error =
448     Cow::Borrowed("Incorrect comment; possible values include `strict`, `partial`, or empty");
449 pub const pair_initializer_needed: Error = Cow::Borrowed("Initializer needed for Pair object");
450 pub const pair_initializer_arity: Error =
451     Cow::Borrowed("Pair objects must have exactly 2 elements");
452 pub const toplevel_statements: Error =
453     Cow::Borrowed("Toplevel statements are not allowed. Use `__EntryPoint` attribute instead");
454 pub const invalid_reified: Error =
455     Cow::Borrowed("`reify` keyword can only appear at function or class type parameter position");
456 pub fn reified_in_invalid_classish(s: &str) -> Error {
457     Cow::Owned(format!(
458         "Invalid to use a reified type within {}'s type parameters",
459         s.to_string(),
460     ))
462 pub const shadowing_reified: Error = Cow::Borrowed("You may not shadow a reified parameter");
463 pub const static_property_in_reified_class: Error =
464     Cow::Borrowed("You may not use static properties in a class with reified type parameters");
465 pub const cls_reified_generic_in_static_method: Error =
466     Cow::Borrowed("You may not use reified generics of the class in a static method");
467 pub const static_method_reified_obj_creation: Error = Cow::Borrowed(
468     "You may not use object creation for potentially reified `self` or `parent` from a static method",
470 pub const non_invariant_reified_generic: Error =
471     Cow::Borrowed("Reified generics cannot be covariant or contravariant");
472 pub const no_generics_on_constructors: Error = Cow::Borrowed(
473     "Generic type parameters are not allowed on constructors. Consider adding a type parameter to the class",
475 pub const no_type_parameters_on_dynamic_method_calls: Error =
476     Cow::Borrowed("Generics type parameters are disallowed on dynamic method calls");
477 pub const dollar_unary: Error =
478     Cow::Borrowed("The dollar sign `$` cannot be used as a unary operator");
479 pub const type_alias_to_type_constant: Error =
480     Cow::Borrowed("Type aliases to type constants are not supported");
481 pub const interface_with_memoize: Error =
482     Cow::Borrowed("`__Memoize` is not allowed on interface methods");
483 pub const nested_concurrent_blocks: Error = Cow::Borrowed("`concurrent` blocks cannot be nested.");
484 pub const fewer_than_two_statements_in_concurrent_block: Error = Cow::Borrowed(concat!(
485     "Expected 2 or more statements in concurrent block. `concurrent` wrapping ",
486     "nothing or a single statement is not useful or already implied.",
488 pub const invalid_syntax_concurrent_block: Error = Cow::Borrowed(concat!(
489     "`concurrent` block must contain a compound statement of two or ",
490     "more expression statements, IE concurrent `{ <expr>; <expr>; }`.",
492 pub const statement_without_await_in_concurrent_block: Error =
493     Cow::Borrowed("Statement without an `await` in a concurrent block");
494 pub const concurrent_is_disabled: Error = Cow::Borrowed("`concurrent` is disabled");
495 pub const invalid_await_position: Error = Cow::Borrowed(concat!(
496     "`await` cannot be used as an expression in this ",
497     "location because it's conditionally executed.",
499 pub const invalid_await_position_dependent: Error = Cow::Borrowed(concat!(
500     "`await` cannot be used as an expression inside another await expression. ",
501     "Pull the inner `await` out into its own statement.",
503 pub const tparams_in_tconst: Error =
504     Cow::Borrowed("Type parameters are not allowed on class type constants");
505 pub const targs_not_allowed: Error =
506     Cow::Borrowed("Type arguments are not allowed in this position");
507 pub const reified_attribute: Error = Cow::Borrowed(
508     "`__Reified` and `__HasReifiedParent` attributes may not be provided by the user",
510 pub const lval_as_expression: Error = Cow::Borrowed(
511     "Assignments can no longer be used as expressions. Pull the assignment out into a separate statement.",
513 pub fn elt_abstract_private(elt: &str) -> Error {
514     Cow::Owned(format!(
515         "Cannot declare abstract {} `private`.",
516         elt.to_string(),
517     ))
519 pub const only_soft_allowed: Error = Cow::Borrowed("Only the `__Soft` attribute is allowed here.");
520 pub const soft_no_arguments: Error =
521     Cow::Borrowed("The `__Soft` attribute does not take arguments.");
522 pub const no_legacy_soft_typehints: Error = Cow::Borrowed(
523     "The `@` syntax for soft typehints is not allowed. Use the `__Soft` attribute instead.",
525 pub const outside_dollar_str_interp: Error =
526     Cow::Borrowed("The `${x}` syntax is disallowed in Hack. Use `{$x}` instead.");
527 pub const no_const_interfaces_traits_enums: Error =
528     Cow::Borrowed("Interfaces, traits and enums may not be declared `__Const`");
529 pub const no_const_late_init_props: Error =
530     Cow::Borrowed("`__Const` properties may not also be `__LateInit`");
531 pub const no_const_static_props: Error = Cow::Borrowed("Static properties may not be `__Const`");
532 pub const no_const_abstract_final_class: Error =
533     Cow::Borrowed("Cannot apply `__Const` attribute to an abstract final class");
534 pub const no_legacy_attribute_syntax: Error = Cow::Borrowed(
535     "The `<<...>>` syntax for user attributes is not allowed. Use the `@` syntax instead.",
537 pub const no_silence: Error = Cow::Borrowed("The error suppression operator `@` is not allowed");
538 pub const const_mutation: Error = Cow::Borrowed("Cannot mutate a class constant");
539 pub const no_attributes_on_variadic_parameter: Error =
540     Cow::Borrowed("Attributes on variadic parameters are not allowed");
541 pub const invalid_constant_initializer: Error =
542     Cow::Borrowed("Expected constant expression for initializer");
543 pub const parent_static_prop_decl: Error =
544     Cow::Borrowed("Cannot use `static` or `parent::class` in property declaration");
545 pub fn error2070(open_tag: &str, close_tag: &str) -> Error {
546     Cow::Owned(format!(
547         "XHP: mismatched tag: `{}` not the same as `{}`",
548         close_tag.to_string(),
549         open_tag.to_string(),
550     ))
552 pub fn error2071(s: &str) -> Error {
553     Cow::Owned(format!("Decimal number is too big: `{}`", s.to_string(),))
555 pub fn error2072(s: &str) -> Error {
556     Cow::Owned(format!(
557         "Hexadecimal number is too big: `{}`",
558         s.to_string(),
559     ))
561 pub const error2073: Error = Cow::Borrowed(concat!(
562     "A variadic parameter `...` cannot have a modifier ",
563     "that changes the calling convention, like `inout`.",
565 pub fn error2074(call_modifier: &str) -> Error {
566     Cow::Owned(format!(
567         "An `{}` parameter must not have a default value.",
568         call_modifier.to_string(),
569     ))
571 pub const error2077: Error = Cow::Borrowed("Cannot use empty list");
572 pub fn not_allowed_in_write(what: &str) -> Error {
573     Cow::Owned(format!(
574         "{} is not allowed in write context",
575         what.to_string(),
576     ))
578 pub const reassign_this: Error = Cow::Borrowed("Cannot re-assign `$this`");
579 pub const enum_elem_name_is_class: Error = Cow::Borrowed("Enum element cannot be named `class`");
580 pub const property_requires_visibility: Error = Cow::Borrowed(concat!(
581     "Property declarations require a visibility modifier ",
582     "such as `public`, `private` or `protected`.",
584 pub const abstract_prop_init: Error =
585     Cow::Borrowed("An `abstract` property must not have an initializer.");
586 pub const const_static_prop_init: Error =
587     Cow::Borrowed("A `const static` property must have an initializer.");
588 pub fn namespace_name_is_already_in_use(name: &str, short_name: &str) -> Error {
589     Cow::Owned(format!(
590         "Cannot use namespace `{}` as `{}` because the name is already in use",
591         name.to_string(),
592         short_name.to_string()
593     ))
595 pub const strict_namespace_hh: Error = Cow::Borrowed(concat!(
596     "To use strict Hack, place `// strict` after the open tag. ",
597     "If it's already there, remove this line. ",
598     "Hack is strict already.",
600 pub fn name_is_already_in_use_hh(line_num: isize, name: &str, short_name: &str) -> Error {
601     Cow::Owned(format!(
602         "Cannot use `{}` as `{}` because the name was explicitly used earlier via a `use` statement on line {}",
603         name.to_string(),
604         short_name.to_string(),
605         line_num.to_string(),
606     ))
608 pub fn name_is_already_in_use_implicit_hh(line_num: isize, name: &str, short_name: &str) -> Error {
609     Cow::Owned(format!(
610         concat!(
611             "Cannot use `{}` as `{}` because the name was implicitly used on line {}",
612             "; implicit use of names from the HH namespace can be suppressed by adding an explicit",
613             " `use` statement earlier in the current namespace block",
614         ),
615         name.to_string(),
616         short_name.to_string(),
617         line_num.to_string(),
618     ))
620 pub fn name_is_already_in_use_php(name: &str, short_name: &str) -> Error {
621     Cow::Owned(format!(
622         "Cannot use `{}` as `{}` because the name is already in use",
623         name.to_string(),
624         short_name.to_string(),
625     ))
627 pub const original_definition: Error = Cow::Borrowed("Original definition");
628 pub fn function_name_is_already_in_use(name: &str, short_name: &str) -> Error {
629     Cow::Owned(format!(
630         "Cannot use function `{}` as `{}` because the name is already in use",
631         name.to_string(),
632         short_name.to_string(),
633     ))
635 pub fn const_name_is_already_in_use(name: &str, short_name: &str) -> Error {
636     Cow::Owned(format!(
637         "Cannot use const `{}` as `{}` because the name is already in use",
638         name.to_string(),
639         short_name.to_string(),
640     ))
642 pub fn type_name_is_already_in_use(name: &str, short_name: &str) -> Error {
643     Cow::Owned(format!(
644         "Cannot use type `{}` as `{}` because the name is already in use",
645         name.to_string(),
646         short_name.to_string(),
647     ))
649 pub const namespace_decl_first_statement: Error = Cow::Borrowed(
650     "Namespace declaration statement has to be the very first statement in the script",
652 pub const code_outside_namespace: Error =
653     Cow::Borrowed("No code may exist outside of namespace {}");
654 pub const global_in_const_decl: Error =
655     Cow::Borrowed("Cannot have globals in constant declaration");
656 pub const parent_static_const_decl: Error =
657     Cow::Borrowed("Cannot use `static` or `parent::class` in constant declaration");
658 pub const no_async_before_lambda_body: Error =
659     Cow::Borrowed("Don't use `() ==> async { ... }`. Instead, use: `async () ==> { ... }`");
660 pub fn invalid_number_of_args(name: &str, n: usize) -> Error {
661     Cow::Owned(format!(
662         "Method `{}` must take exactly {} arguments",
663         name.to_string(),
664         n.to_string(),
665     ))
667 pub fn invalid_inout_args(name: &str) -> Error {
668     Cow::Owned(format!(
669         "Method `{}` cannot take inout arguments",
670         name.to_string(),
671     ))
673 pub fn redeclaration_error(name: &str) -> Error {
674     Cow::Owned(format!("Cannot redeclare `{}`", name.to_string(),))
676 pub fn declared_name_is_already_in_use_implicit_hh(
677     line_num: usize,
678     name: &str,
679     _short_name: &str,
680 ) -> Error {
681     Cow::Owned(format!(
682         concat!(
683             "Cannot declare `{}` because the name was implicitly used on line {}; ",
684             "implicit use of names from the HH namespace can be suppressed by adding an explicit ",
685             "`use` statement earlier in the current namespace block",
686         ),
687         name.to_string(),
688         line_num.to_string(),
689     ))
691 pub fn declared_name_is_already_in_use(line_num: usize, name: &str, _short_name: &str) -> Error {
692     Cow::Owned(format!(
693         concat!(
694             "Cannot declare `{}` because the name was explicitly used earlier via a `use` ",
695             "statement on line {}",
696         ),
697         name.to_string(),
698         line_num.to_string(),
699     ))
701 pub const sealed_val_not_classname: Error =
702     Cow::Borrowed("Values in sealed whitelist must be classname constants.");
703 pub const sealed_qualifier_invalid: Error =
704     Cow::Borrowed("`__Sealed` can only be used with named types, e.g. `Foo::class`");
705 pub const list_must_be_lvar: Error =
706     Cow::Borrowed("`list()` can only be used as an lvar. Did you mean to use `tuple()`?");
707 pub const async_not_last: Error =
708     Cow::Borrowed("The `async` modifier must be directly before the `function` keyword.");
709 pub const using_st_function_scoped_top_level: Error = Cow::Borrowed(concat!(
710     "Using statement in function scoped form may only be used at the top ",
711     "level of a function or a method",
713 pub const double_variadic: Error = Cow::Borrowed("Parameter redundantly marked as variadic `...`.");
714 pub fn conflicting_trait_require_clauses(name: &str) -> Error {
715     Cow::Owned(format!(
716         "Conflicting requirements for `{}`",
717         name.to_string(),
718     ))
720 pub const shape_type_ellipsis_without_trailing_comma: Error =
721     Cow::Borrowed("A comma is required before the `...` in a shape type");
722 pub const yield_in_magic_methods: Error =
723     Cow::Borrowed("`yield` is not allowed in constructors or magic methods");
724 pub const yield_outside_function: Error =
725     Cow::Borrowed("`yield` can only be used inside a function");
726 pub const coloncolonclass_on_dynamic: Error =
727     Cow::Borrowed("Dynamic class names are not allowed in compile-time `::class` fetch");
728 pub const this_in_static: Error =
729     Cow::Borrowed("Don't use `$this` in a static method, use `static::` instead");
730 pub fn async_magic_method(name: &str) -> Error {
731     Cow::Owned(format!(
732         "Cannot declare constructors and magic methods like `{}` as `async`",
733         name.to_string(),
734     ))
736 pub fn unsupported_magic_method(name: &str) -> Error {
737     Cow::Owned(format!(
738         "Magic `{}` methods are no longer supported",
739         name.to_string(),
740     ))
742 pub fn reserved_keyword_as_class_name(class_name: &str) -> Error {
743     Cow::Owned(format!(
744         "Cannot use `{}` as class name as it is reserved",
745         class_name.to_string(),
746     ))
748 pub const xhp_class_multiple_category_decls: Error =
749     Cow::Borrowed("An XHP class cannot have multiple category declarations");
750 pub const xhp_class_multiple_children_decls: Error =
751     Cow::Borrowed("An XHP class cannot have multiple children declarations");
752 pub const inout_param_in_generator: Error =
753     Cow::Borrowed("Parameters may not be marked `inout` on generators");
754 pub const inout_param_in_async_generator: Error =
755     Cow::Borrowed("Parameters may not be marked `inout` on `async` generators");
756 pub const inout_param_in_async: Error =
757     Cow::Borrowed("Parameters may not be marked `inout` on `async` functions");
758 pub const inout_param_in_construct: Error =
759     Cow::Borrowed("Parameters may not be marked `inout` on constructors");
760 pub const fun_arg_inout_set: Error =
761     Cow::Borrowed("You cannot set an `inout` decorated argument while calling a function");
762 pub const fun_arg_inout_const: Error = Cow::Borrowed("You cannot decorate a constant as `inout`");
763 pub const fun_arg_invalid_arg: Error =
764     Cow::Borrowed("You cannot decorate this argument as `inout`");
765 pub const fun_arg_inout_containers: Error = Cow::Borrowed(concat!(
766     "Parameters marked `inout` must be contained in locals, vecs, dicts, keysets,",
767     " and arrays",
769 pub const memoize_with_inout: Error =
770     Cow::Borrowed("`<<__Memoize>>` cannot be used on functions with `inout` parameters");
771 pub const method_calls_on_xhp_attributes: Error =
772     Cow::Borrowed("Method calls are not allowed on XHP attributes");
773 pub const method_calls_on_xhp_expression: Error =
774     Cow::Borrowed("Please add parentheses around the XHP component");
775 pub fn class_with_abstract_method(name: &str) -> Error {
776     Cow::Owned(format!(
777         concat!(
778             "Class `{}` contains an abstract method and must ",
779             "therefore be declared `abstract`",
780         ),
781         name.to_string(),
782     ))
784 pub const interface_has_private_method: Error =
785     Cow::Borrowed("Interface methods must be `public` or `protected`");
786 pub fn redeclaration_of_function(name: &str, loc: &str) -> Error {
787     Cow::Owned(format!(
788         "Cannot redeclare `{}()` (previously declared in {})",
789         name.to_string(),
790         loc.to_string()
791     ))
793 pub fn redeclaration_of_method(name: &str) -> Error {
794     Cow::Owned(format!("Redeclared method `{}`", name.to_string(),))
796 pub fn self_or_parent_colon_colon_class_outside_of_class(name: &str) -> Error {
797     Cow::Owned(format!(
798         "Cannot access `{}::class` when no class scope is active",
799         name.to_string(),
800     ))
802 pub fn invalid_is_as_expression_hint(n: &str, hint: &str) -> Error {
803     Cow::Owned(format!(
804         "`{}` typehints cannot be used with `{}` expressions",
805         hint.to_string(),
806         n.to_string(),
807     ))
809 pub const elvis_operator_space: Error = Cow::Borrowed("An Elvis operator `?:` is expected here.");
810 pub fn clone_takes_no_arguments(class_name: &str, method_name: &str) -> Error {
811     Cow::Owned(format!(
812         "Method `{}::{}` cannot accept any arguments",
813         class_name.to_string(),
814         method_name.to_string(),
815     ))
817 pub fn clone_cannot_be_static(class_name: &str, method_name: &str) -> Error {
818     Cow::Owned(format!(
819         "Clone method `{}::{}()` cannot be static",
820         class_name.to_string(),
821         method_name.to_string(),
822     ))
824 pub const namespace_not_a_classname: Error =
825     Cow::Borrowed("Namespace cannot be used as a classname");
826 pub const for_with_as_expression: Error =
827     Cow::Borrowed("For loops can not use `as` expressions. Did you mean `foreach`?");
828 pub const sealed_final: Error = Cow::Borrowed("Classes cannot be both `final` and `sealed`.");
829 pub const interface_implements: Error =
830     Cow::Borrowed("Interfaces may not implement other interfaces or classes");
831 pub const memoize_on_lambda: Error =
832     Cow::Borrowed("`<<__Memoize>>` attribute is not allowed on lambdas or anonymous functions.");
833 pub fn declared_final(elt: &str) -> Error {
834     Cow::Owned(format!("{} cannot be declared `final`.", elt.to_string(),))
836 pub fn invalid_xhp_classish(elt: &str) -> Error {
837     Cow::Owned(format!("{} are not valid xhp classes.", elt.to_string(),))
839 pub const empty_method_name: Error = Cow::Borrowed("Expected a method name");
840 pub fn lowering_parsing_error(text: &str, syntax: &str) -> Error {
841     Cow::Owned(format!(
842         "Encountered unexpected text `{}`, was expecting a {}.",
843         text.to_string(),
844         syntax.to_string(),
845     ))
847 pub const xhp_class_attribute_type_constant: Error =
848     Cow::Borrowed("Type constants are not allowed on xhp class attributes");
849 pub const globals_disallowed: Error =
850     Cow::Borrowed("`$GLOBALS` variable is removed from the language. Use HH\\global functions");
851 pub const invalid_this: Error =
852     Cow::Borrowed("`$this` cannot be used in functions and static methods");
853 pub const cannot_unset_this: Error = Cow::Borrowed("`$this` cannot be unset");
854 pub const invalid_await_position_pipe: Error =
855     Cow::Borrowed("`await` cannot be used as an expression right of a pipe operator.");
856 pub fn invalid_modifier_for_declaration(decl: &str, modifier: &str) -> Error {
857     Cow::Owned(format!(
858         "{} cannot be declared `{}`",
859         decl.to_string(),
860         modifier.to_string(),
861     ))
863 pub fn duplicate_modifiers_for_declaration(decl: &str) -> Error {
864     Cow::Owned(format!(
865         "{} cannot have duplicate modifiers",
866         decl.to_string(),
867     ))
869 pub fn multiple_visibility_modifiers_for_declaration(decl: &str) -> Error {
870     Cow::Owned(format!(
871         "{} cannot have multiple visibility modifiers",
872         decl.to_string(),
873     ))
875 pub const break_continue_n_not_supported: Error =
876     Cow::Borrowed("`break`/`continue N` operators are not supported.");
877 pub fn invalid_typehint_alias(alias: &str, hint: &str) -> Error {
878     Cow::Owned(format!(
879         "Invalid type hint `{}`. Use `{}` instead",
880         alias.to_string(),
881         hint.to_string(),
882     ))
885 pub const function_pointer_bad_recv: Error = Cow::Borrowed(concat!(
886     "Function pointers `<>` can only be created with toplevel functions and explicitly named static methods. ",
887     "Use lambdas `(...) ==> {...}` for other cases."
890 pub const local_variable_with_type: Error =
891     Cow::Borrowed("Local variables cannot have type annotations in Hack.");
893 pub const empty_expression_illegal: Error =
894     Cow::Borrowed("The `empty()` expression has been removed from Hack.");
896 pub const empty_switch_cases: Error =
897     Cow::Borrowed("`switch` statements need to have at least one `case` or a `default` block");
899 pub const preceding_backslash: Error = Cow::Borrowed("Unnecessary preceding backslash");
901 pub fn multiple_entrypoints(loc: &str) -> Error {
902     Cow::Owned(format!(
903         "Only one `__EntryPoint` annotation is permitted per file (previous `__EntryPoint` annotation in {})",
904         loc.to_string()
905     ))
908 pub fn cannot_use_feature(feature: &str) -> Error {
909     Cow::Owned(format!(
910         "Cannot use unstable feature: `{}`",
911         feature.to_string()
912     ))
915 pub fn cannot_enable_unstable_feature(message: &str) -> Error {
916     Cow::Owned(format!(
917         "Cannot enable unstable feature: {}",
918         message.to_string()
919     ))
922 pub fn invalid_use_of_enable_unstable_feature(message: &str) -> Error {
923     Cow::Owned(format!(
924         "This is an invalid use of `__EnableUnstableFeatures` because {}",
925         message.to_string()
926     ))
929 pub const splice_outside_et: Error =
930     Cow::Borrowed("Splicing can only occur inside expression tree literals (between backticks)");
932 pub const invalid_enum_class_enumerator: Error = Cow::Borrowed("Invalid enum class constant");
934 pub fn fun_disabled(func_name: &str) -> Error {
935     Cow::Owned(format!(
936         "`fun()` is disabled; switch to first-class references like `{}<>`",
937         func_name
938             .trim_end_matches('\'')
939             .trim_start_matches('\'')
940             .to_string()
941     ))
944 pub const fun_requires_const_string: Error = Cow::Borrowed("Constant string expected in fun()");
946 pub const class_meth_disabled: Error =
947     Cow::Borrowed("`class_meth()` is disabled; switch to first-class references like `C::bar<>`");
949 pub fn ctx_var_invalid_parameter(param_name: &str) -> Error {
950     Cow::Owned(format!(
951         "Could not find parameter {} for dependent context",
952         param_name.to_string()
953     ))
956 pub fn ctx_var_missing_type_hint(param_name: &str) -> Error {
957     Cow::Owned(format!(
958         "Parameter {} used for dependent context must have a type hint",
959         param_name.to_string()
960     ))
963 pub fn ctx_var_variadic(param_name: &str) -> Error {
964     Cow::Owned(format!(
965         "Parameter {} used for dependent context cannot be variadic",
966         param_name.to_string()
967     ))
970 pub fn ctx_var_invalid_type_hint(param_name: &str) -> Error {
971     Cow::Owned(format!(
972         "Type hint for parameter {} used for dependent context must be a class or a generic",
973         param_name.to_string()
974     ))
977 pub fn ctx_fun_invalid_type_hint(param_name: &str) -> Error {
978     Cow::Owned(format!(
979         "Type hint for parameter {} used for contextful function must be a function type hint whose context is exactly `[_]`, e.g. `(function (ts)[_]: t)`",
980         param_name.to_string()
981     ))
984 pub fn ctx_generic_invalid(tparam_name: &str, ctx: String) -> Error {
985     Cow::Owned(format!(
986         "Type parameter {} used for dependent context {} must be reified",
987         tparam_name.to_string(),
988         ctx
989     ))
992 pub fn effect_polymorphic_memoized(kind: &str) -> Error {
993     Cow::Owned(format!(
994         "This {} cannot be memoized because it has a polymorphic context",
995         kind
996     ))
999 pub fn effect_policied_memoized(kind: &str) -> Error {
1000     Cow::Owned(format!(
1001         "This {} can only be memoized using __PolicyShardedMemoize or __PolicyShardedMemoizeLSB because it has policied context",
1002         kind
1003     ))
1006 pub fn policy_sharded_memoized_without_policied(kind: &str) -> Error {
1007     Cow::Owned(format!(
1008         "This {} requires a policied context to be memoized using __PolicyShardedMemoize or __PolicyShardedMemoizeLSB",
1009         kind
1010     ))
1013 pub const lambda_effect_polymorphic: Error =
1014     Cow::Borrowed("A lambda cannot have polymorphic context");
1016 pub const inst_meth_disabled: Error =
1017     Cow::Borrowed("`inst_meth()` is disabled; use a lambda `(...) ==> {...}` instead");
1019 pub fn invalid_via_label_location() -> Error {
1020     Cow::Owned(format!(
1021         "`{}` attribute can only appear on the first parameter of a function",
1022         ua::VIA_LABEL.to_string()
1023     ))
1026 pub const as_mut_single_argument: Error =
1027     Cow::Borrowed("HH\\Readonly\\as_mut takes a single value-typed expression as an argument.");
1029 pub fn out_of_int_range(int: &str) -> Error {
1030     Cow::Owned(format!(
1031         "{} is out of the range of 64-bit float values",
1032         int.to_string(),
1033     ))
1036 pub fn out_of_float_range(float: &str) -> Error {
1037     Cow::Owned(format!(
1038         "{} is out of the range of 64-bit float values",
1039         float.to_string(),
1040     ))
1043 pub fn user_ctx_should_be_caps(ctx_name: &str) -> Error {
1044     Cow::Owned(format!(
1045         "Context {} should begin with an uppercase letter",
1046         ctx_name.to_string()
1047     ))
1050 pub fn user_ctx_require_as(ctx_name: &str) -> Error {
1051     Cow::Owned(format!(
1052         "Context {} must declare a context constraint e.g. `as [write_props]`",
1053         ctx_name.to_string()
1054     ))
1057 pub const assignment_to_readonly: Error =
1058     Cow::Borrowed("This expression is readonly, its members cannot be modified");
1060 pub const assign_readonly_to_mutable_collection: Error = Cow::Borrowed(
1061     "This expression is readonly, but the collection you're modifying is mutable, which isn't allowed.",
1064 pub fn invalid_readonly(r1: &str, r2: &str, reason: &str) -> Error {
1065     Cow::Owned(format!(
1066         "This expression is {}, but we expected a {} value because {}",
1067         r1.to_string(),
1068         r2.to_string(),
1069         reason.to_string()
1070     ))
1073 pub const inout_readonly_assignment: Error =
1074     Cow::Borrowed("Cannot write a readonly value to an inout parameter");
1076 pub const inout_readonly_parameter: Error =
1077     Cow::Borrowed("Inout readonly parameters are not currently supported");
1079 pub const enum_class_constant_missing_initializer: Error =
1080     Cow::Borrowed("Concrete enum class constants must have an initial value");
1082 pub const enum_class_abstract_constant_with_value: Error =
1083     Cow::Borrowed("Abstract enum class constants must not provide any initial value");
1085 pub const enum_with_modifiers: Error = Cow::Borrowed("Enums can't have any modifiers");
1087 pub const readonly_static_method: Error =
1088     Cow::Borrowed("Static methods do not need to be marked readonly");
1089 pub const variadic_readonly_param: Error =
1090     Cow::Borrowed("Variadic parameters cannot be marked readonly");
1091 pub const throw_readonly_exception: Error = Cow::Borrowed(
1092     "This exception is readonly; throwing readonly exceptions is not currently supported.",
1094 pub const direct_coeffects_reference: Error =
1095     Cow::Borrowed("Direct references to coeffects namespaces are not allowed");