Skip to main content

luaur_analysis/functions/
to_string_error_alt_k.rs

1use crate::records::error_converter::ErrorConverter;
2use crate::records::type_error::TypeError;
3use crate::records::type_error_to_string_options::TypeErrorToStringOptions;
4use crate::type_aliases::type_error_data::TypeErrorData;
5use alloc::string::String;
6
7/// C++ `std::string toString(const TypeError& error, TypeErrorToStringOptions options)`.
8pub fn to_string_type_error_type_error_to_string_options(
9    error: &TypeError,
10    options: TypeErrorToStringOptions,
11) -> String {
12    let converter = ErrorConverter::new(options.file_resolver);
13    match &error.data {
14        TypeErrorData::TypeMismatch(e) => converter.operator_call_40(e),
15        TypeErrorData::UnknownSymbol(e) => converter.operator_call_45(e),
16        TypeErrorData::UnknownProperty(e) => converter.operator_call_43(e),
17        TypeErrorData::NotATable(e) => converter.operator_call_34(e),
18        TypeErrorData::CannotExtendTable(e) => converter.operator_call_15(e),
19        TypeErrorData::CannotCompareUnrelatedTypes(e) => converter.operator_call_14(e),
20        TypeErrorData::OnlyTablesCanHaveMethods(e) => converter.operator_call_36(e),
21        TypeErrorData::DuplicateTypeDefinition(e) => converter.operator_call_22(e),
22        TypeErrorData::CountMismatch(e) => converter.operator_call_19(e),
23        TypeErrorData::FunctionDoesNotTakeSelf(e) => converter.operator_call_24(e),
24        TypeErrorData::FunctionRequiresSelf(e) => converter.operator_call_26(e),
25        TypeErrorData::OccursCheckFailed(e) => converter.operator_call_35(e),
26        TypeErrorData::UnknownRequire(e) => converter.operator_call_44(e),
27        TypeErrorData::IncorrectGenericParameterCount(e) => converter.operator_call_29(e),
28        TypeErrorData::SyntaxError(e) => converter.operator_call_39(e),
29        TypeErrorData::CodeTooComplex(e) => converter.operator_call_17(e),
30        TypeErrorData::UnificationTooComplex(e) => converter.operator_call_41(e),
31        TypeErrorData::UnknownPropButFoundLikeProp(e) => converter.operator_call_42(e),
32        TypeErrorData::GenericError(e) => converter.operator_call_27(e),
33        TypeErrorData::InternalError(e) => converter.operator_call_30(e),
34        TypeErrorData::ConstraintSolvingIncompleteError(e) => converter.operator_call_18(e),
35        TypeErrorData::CannotCallNonFunction(e) => converter.operator_call_13(e),
36        TypeErrorData::ExtraInformation(e) => converter.operator_call_23(e),
37        TypeErrorData::DeprecatedApiUsed(e) => converter.operator_call_20(e),
38        TypeErrorData::ModuleHasCyclicDependency(e) => converter.operator_call_33(e),
39        TypeErrorData::IllegalRequire(e) => converter.operator_call_28(e),
40        TypeErrorData::FunctionExitsWithoutReturning(e) => converter.operator_call_25(e),
41        TypeErrorData::DuplicateGenericParameter(e) => converter.operator_call_21(e),
42        TypeErrorData::CannotAssignToNever(e) => converter.operator_call_3(e),
43        TypeErrorData::CannotInferBinaryOperation(e) => converter.operator_call_16(e),
44        TypeErrorData::MissingProperties(e) => converter.operator_call_31(e),
45        TypeErrorData::SwappedGenericTypeParameter(e) => converter.operator_call_38(e),
46        TypeErrorData::OptionalValueAccess(e) => converter.operator_call_37(e),
47        TypeErrorData::MissingUnionProperty(e) => converter.operator_call_32(e),
48        TypeErrorData::TypesAreUnrelated(e) => converter.operator_call_55(e),
49        TypeErrorData::NormalizationTooComplex(e) => converter.operator_call_48(e),
50        TypeErrorData::TypePackMismatch(e) => converter.operator_call_54(e),
51        TypeErrorData::DynamicPropertyLookupOnExternTypesUnsafe(e) => converter.operator_call_7(e),
52        TypeErrorData::UninhabitedTypeFunction(e) => converter.operator_call_60(e),
53        TypeErrorData::UninhabitedTypePackFunction(e) => converter.operator_call_61(e),
54        TypeErrorData::WhereClauseNeeded(e) => converter.operator_call_63(e),
55        TypeErrorData::PackWhereClauseNeeded(e) => converter.operator_call_49(e),
56        TypeErrorData::CheckedFunctionCallError(e) => converter.operator_call_5(e),
57        TypeErrorData::NonStrictFunctionDefinitionError(e) => converter.operator_call_47(e),
58        TypeErrorData::PropertyAccessViolation(e) => converter.operator_call_50(e),
59        TypeErrorData::CheckedFunctionIncorrectArgs(e) => converter.operator_call_6(e),
60        TypeErrorData::UnexpectedTypeInSubtyping(e) => converter.operator_call_58(e),
61        TypeErrorData::UnexpectedTypePackInSubtyping(e) => converter.operator_call_59(e),
62        TypeErrorData::ExplicitFunctionAnnotationRecommended(e) => converter.operator_call_8(e),
63        TypeErrorData::UserDefinedTypeFunctionError(e) => converter.operator_call_62(e),
64        TypeErrorData::BuiltInTypeFunctionError(e) => converter.operator_call_2(e),
65        TypeErrorData::ReservedIdentifier(e) => converter.operator_call_52(e),
66        TypeErrorData::UnexpectedArrayLikeTableItem(e) => converter.operator_call_57(e),
67        TypeErrorData::CannotCheckDynamicStringFormatCalls(e) => converter.operator_call_4(e),
68        TypeErrorData::GenericTypeCountMismatch(e) => converter.operator_call_10(e),
69        TypeErrorData::GenericTypePackCountMismatch(e) => converter.operator_call_11(e),
70        TypeErrorData::MultipleNonviableOverloads(e) => converter.operator_call_46(e),
71        TypeErrorData::RecursiveRestraintViolation(e) => converter.operator_call_51(e),
72        TypeErrorData::GenericBoundsMismatch(e) => converter.operator_call_9(e),
73        TypeErrorData::UnappliedTypeFunction(e) => converter.operator_call_56(e),
74        TypeErrorData::InstantiateGenericsOnNonFunction(e) => converter.operator_call_12(e),
75        TypeErrorData::TypeInstantiationCountMismatch(e) => converter.operator_call_53(e),
76        TypeErrorData::AmbiguousFunctionCall(e) => converter.operator_call(e),
77    }
78}