src/exception/SemanticError.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Copyright (c) 2021-2026 ChilliBits. All rights reserved. | ||
| 2 | |||
| 3 | #include "SemanticError.h" | ||
| 4 | |||
| 5 | #include <ast/ASTNodes.h> | ||
| 6 | #include <util/CodeLoc.h> | ||
| 7 | |||
| 8 | namespace spice::compiler { | ||
| 9 | |||
| 10 | 606 | SemanticError::SemanticError(const ASTNode *node, const SemanticErrorType &type, const std::string &msg, bool printErrorMessage) { | |
| 11 |
1/2✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 606 times.
|
606 | assert(node != nullptr); |
| 12 |
3/6✓ Branch 6 → 7 taken 606 times.
✗ Branch 6 → 32 not taken.
✓ Branch 7 → 8 taken 606 times.
✗ Branch 7 → 30 not taken.
✓ Branch 8 → 9 taken 606 times.
✗ Branch 8 → 28 not taken.
|
606 | errorMessage = "[Error|Semantic] " + node->codeLoc.toPrettyString() + ":\n"; |
| 13 |
4/8✓ Branch 13 → 14 taken 606 times.
✗ Branch 13 → 41 not taken.
✓ Branch 14 → 15 taken 606 times.
✗ Branch 14 → 39 not taken.
✓ Branch 15 → 16 taken 606 times.
✗ Branch 15 → 37 not taken.
✓ Branch 16 → 17 taken 606 times.
✗ Branch 16 → 35 not taken.
|
606 | errorMessage += getMessagePrefix(type) + ": " + msg; |
| 14 |
2/2✓ Branch 20 → 21 taken 602 times.
✓ Branch 20 → 27 taken 4 times.
|
606 | if (printErrorMessage) { |
| 15 |
1/2✓ Branch 21 → 22 taken 602 times.
✗ Branch 21 → 49 not taken.
|
602 | const std::string nodeErrorMessage = node->getErrorMessage(); |
| 16 |
2/4✓ Branch 22 → 23 taken 602 times.
✗ Branch 22 → 46 not taken.
✓ Branch 23 → 24 taken 602 times.
✗ Branch 23 → 44 not taken.
|
602 | errorMessage += "\n\n" + nodeErrorMessage; |
| 17 | 602 | } | |
| 18 | 606 | } | |
| 19 | |||
| 20 | /** | ||
| 21 | * Get the message for this particular error instance | ||
| 22 | * | ||
| 23 | * @return Error message in form of a char array | ||
| 24 | */ | ||
| 25 | 606 | const char *SemanticError::what() const noexcept { return errorMessage.c_str(); } | |
| 26 | |||
| 27 | /** | ||
| 28 | * Get the prefix of the error message for a particular error | ||
| 29 | * | ||
| 30 | * @param errorType Type of the error | ||
| 31 | * @return Prefix string for the error type | ||
| 32 | */ | ||
| 33 | 606 | std::string SemanticError::getMessagePrefix(SemanticErrorType errorType) { | |
| 34 |
90/120✓ Branch 2 → 3 taken 34 times.
✓ Branch 2 → 9 taken 14 times.
✓ Branch 2 → 15 taken 8 times.
✗ Branch 2 → 21 not taken.
✗ Branch 2 → 27 not taken.
✗ Branch 2 → 33 not taken.
✓ Branch 2 → 39 taken 4 times.
✗ Branch 2 → 45 not taken.
✗ Branch 2 → 51 not taken.
✗ Branch 2 → 57 not taken.
✓ Branch 2 → 63 taken 14 times.
✓ Branch 2 → 69 taken 8 times.
✓ Branch 2 → 75 taken 2 times.
✓ Branch 2 → 81 taken 4 times.
✓ Branch 2 → 87 taken 2 times.
✗ Branch 2 → 93 not taken.
✗ Branch 2 → 99 not taken.
✓ Branch 2 → 105 taken 4 times.
✗ Branch 2 → 111 not taken.
✓ Branch 2 → 117 taken 14 times.
✗ Branch 2 → 123 not taken.
✗ Branch 2 → 129 not taken.
✓ Branch 2 → 135 taken 12 times.
✗ Branch 2 → 141 not taken.
✗ Branch 2 → 147 not taken.
✗ Branch 2 → 153 not taken.
✓ Branch 2 → 159 taken 2 times.
✓ Branch 2 → 165 taken 2 times.
✗ Branch 2 → 171 not taken.
✓ Branch 2 → 177 taken 2 times.
✓ Branch 2 → 183 taken 8 times.
✓ Branch 2 → 189 taken 12 times.
✓ Branch 2 → 195 taken 2 times.
✓ Branch 2 → 201 taken 4 times.
✓ Branch 2 → 207 taken 2 times.
✓ Branch 2 → 213 taken 2 times.
✓ Branch 2 → 219 taken 64 times.
✓ Branch 2 → 225 taken 4 times.
✓ Branch 2 → 231 taken 18 times.
✓ Branch 2 → 237 taken 28 times.
✓ Branch 2 → 243 taken 10 times.
✓ Branch 2 → 249 taken 2 times.
✓ Branch 2 → 255 taken 4 times.
✓ Branch 2 → 261 taken 4 times.
✓ Branch 2 → 267 taken 6 times.
✓ Branch 2 → 273 taken 4 times.
✓ Branch 2 → 279 taken 4 times.
✓ Branch 2 → 285 taken 4 times.
✓ Branch 2 → 291 taken 4 times.
✓ Branch 2 → 297 taken 14 times.
✓ Branch 2 → 303 taken 4 times.
✓ Branch 2 → 309 taken 4 times.
✓ Branch 2 → 315 taken 4 times.
✓ Branch 2 → 321 taken 4 times.
✓ Branch 2 → 327 taken 2 times.
✓ Branch 2 → 333 taken 6 times.
✗ Branch 2 → 339 not taken.
✓ Branch 2 → 345 taken 8 times.
✓ Branch 2 → 351 taken 2 times.
✓ Branch 2 → 357 taken 2 times.
✗ Branch 2 → 363 not taken.
✓ Branch 2 → 369 taken 2 times.
✓ Branch 2 → 375 taken 4 times.
✓ Branch 2 → 381 taken 2 times.
✓ Branch 2 → 387 taken 4 times.
✓ Branch 2 → 393 taken 2 times.
✓ Branch 2 → 399 taken 2 times.
✓ Branch 2 → 405 taken 2 times.
✓ Branch 2 → 411 taken 2 times.
✓ Branch 2 → 417 taken 2 times.
✓ Branch 2 → 423 taken 2 times.
✓ Branch 2 → 429 taken 4 times.
✗ Branch 2 → 435 not taken.
✓ Branch 2 → 441 taken 24 times.
✓ Branch 2 → 447 taken 30 times.
✓ Branch 2 → 453 taken 18 times.
✓ Branch 2 → 459 taken 16 times.
✓ Branch 2 → 465 taken 4 times.
✓ Branch 2 → 471 taken 4 times.
✓ Branch 2 → 477 taken 2 times.
✓ Branch 2 → 483 taken 2 times.
✓ Branch 2 → 489 taken 4 times.
✗ Branch 2 → 495 not taken.
✗ Branch 2 → 501 not taken.
✗ Branch 2 → 507 not taken.
✓ Branch 2 → 513 taken 2 times.
✓ Branch 2 → 519 taken 2 times.
✓ Branch 2 → 525 taken 6 times.
✓ Branch 2 → 531 taken 16 times.
✓ Branch 2 → 537 taken 6 times.
✓ Branch 2 → 543 taken 12 times.
✗ Branch 2 → 549 not taken.
✓ Branch 2 → 555 taken 6 times.
✗ Branch 2 → 561 not taken.
✓ Branch 2 → 567 taken 2 times.
✗ Branch 2 → 573 not taken.
✓ Branch 2 → 579 taken 4 times.
✗ Branch 2 → 585 not taken.
✗ Branch 2 → 591 not taken.
✓ Branch 2 → 597 taken 4 times.
✗ Branch 2 → 603 not taken.
✗ Branch 2 → 609 not taken.
✓ Branch 2 → 615 taken 6 times.
✓ Branch 2 → 621 taken 2 times.
✓ Branch 2 → 627 taken 2 times.
✓ Branch 2 → 633 taken 2 times.
✓ Branch 2 → 639 taken 4 times.
✓ Branch 2 → 645 taken 2 times.
✓ Branch 2 → 651 taken 2 times.
✓ Branch 2 → 657 taken 4 times.
✓ Branch 2 → 663 taken 2 times.
✓ Branch 2 → 669 taken 2 times.
✓ Branch 2 → 675 taken 4 times.
✗ Branch 2 → 681 not taken.
✓ Branch 2 → 687 taken 4 times.
✓ Branch 2 → 693 taken 2 times.
✓ Branch 2 → 699 taken 2 times.
✓ Branch 2 → 705 taken 2 times.
✓ Branch 2 → 711 taken 10 times.
✗ Branch 2 → 717 not taken.
|
606 | switch (errorType) { |
| 35 | 34 | case REFERENCED_UNDEFINED_FUNCTION: | |
| 36 |
1/2✓ Branch 5 → 6 taken 34 times.
✗ Branch 5 → 719 not taken.
|
68 | return "Referenced undefined function"; |
| 37 | 14 | case REFERENCED_UNDEFINED_VARIABLE: | |
| 38 |
1/2✓ Branch 11 → 12 taken 14 times.
✗ Branch 11 → 722 not taken.
|
28 | return "Referenced undefined variable"; |
| 39 | 8 | case REFERENCED_UNDEFINED_STRUCT: | |
| 40 |
1/2✓ Branch 17 → 18 taken 8 times.
✗ Branch 17 → 725 not taken.
|
16 | return "Referenced undefined struct"; |
| 41 | ✗ | case REFERENCED_UNDEFINED_INTERFACE: | |
| 42 | ✗ | return "Referenced undefined interface"; | |
| 43 | ✗ | case REFERENCED_UNDEFINED_UNION: | |
| 44 | ✗ | return "Referenced undefined union"; | |
| 45 | ✗ | case REFERENCED_UNDEFINED_FIELD: | |
| 46 | ✗ | return "Referenced undefined struct field"; | |
| 47 | 4 | case USED_BEFORE_DECLARED: | |
| 48 |
1/2✓ Branch 41 → 42 taken 4 times.
✗ Branch 41 → 737 not taken.
|
8 | return "Used before declared"; |
| 49 | ✗ | case FUNCTION_AMBIGUITY: | |
| 50 | ✗ | return "Function ambiguity"; | |
| 51 | ✗ | case STRUCT_AMBIGUITY: | |
| 52 | ✗ | return "Struct ambiguity"; | |
| 53 | ✗ | case INTERFACE_AMBIGUITY: | |
| 54 | ✗ | return "Interface ambiguity"; | |
| 55 | 14 | case DUPLICATE_SYMBOL: | |
| 56 |
1/2✓ Branch 65 → 66 taken 14 times.
✗ Branch 65 → 749 not taken.
|
28 | return "Duplicate symbol"; |
| 57 | 8 | case VARIABLE_DECLARED_TWICE: | |
| 58 |
1/2✓ Branch 71 → 72 taken 8 times.
✗ Branch 71 → 752 not taken.
|
16 | return "Multiple declarations of the same variable"; |
| 59 | 2 | case GLOBAL_DECLARED_TWICE: | |
| 60 |
1/2✓ Branch 77 → 78 taken 2 times.
✗ Branch 77 → 755 not taken.
|
4 | return "Multiple declarations of the same global variable"; |
| 61 | 4 | case FUNCTION_DECLARED_TWICE: | |
| 62 |
1/2✓ Branch 83 → 84 taken 4 times.
✗ Branch 83 → 758 not taken.
|
8 | return "Multiple declarations of a function"; |
| 63 | 2 | case PROCEDURE_DECLARED_TWICE: | |
| 64 |
1/2✓ Branch 89 → 90 taken 2 times.
✗ Branch 89 → 761 not taken.
|
4 | return "Multiple declarations of a procedure"; |
| 65 | ✗ | case GENERIC_TYPE_DECLARED_TWICE: | |
| 66 | ✗ | return "Multiple declarations of a generic type with the same name"; | |
| 67 | ✗ | case STRUCT_WITH_ILLEGAL_NAME: | |
| 68 | ✗ | return "Struct name illegal"; | |
| 69 | 4 | case STRUCT_INFINITE_SIZE: | |
| 70 |
1/2✓ Branch 107 → 108 taken 4 times.
✗ Branch 107 → 770 not taken.
|
8 | return "Struct with infinite size"; |
| 71 | ✗ | case STRUCT_DECLARED_TWICE: | |
| 72 | ✗ | return "Multiple declarations of a struct with the same name"; | |
| 73 | 14 | case NO_MATCHING_CTOR_FOUND: | |
| 74 |
1/2✓ Branch 119 → 120 taken 14 times.
✗ Branch 119 → 776 not taken.
|
28 | return "No matching ctor found"; |
| 75 | ✗ | case COPY_CTOR_REQUIRED: | |
| 76 | ✗ | return "Missing mandatory copy ctor"; | |
| 77 | ✗ | case INTERFACE_DECLARED_TWICE: | |
| 78 | ✗ | return "Multiple declarations of an interface with the same name"; | |
| 79 | 12 | case INTERFACE_METHOD_NOT_IMPLEMENTED: | |
| 80 |
1/2✓ Branch 137 → 138 taken 12 times.
✗ Branch 137 → 785 not taken.
|
24 | return "Interface method not implemented"; |
| 81 | ✗ | case ENUM_DECLARED_TWICE: | |
| 82 | ✗ | return "Multiple declarations of an enum with the same name"; | |
| 83 | ✗ | case INVALID_SYMBOL_ACCESS: | |
| 84 | ✗ | return "Invalid symbol access"; | |
| 85 | ✗ | case DUPLICATE_ENUM_ITEM_NAME: | |
| 86 | ✗ | return "Duplicate enum item name"; | |
| 87 | 2 | case DUPLICATE_ENUM_ITEM_VALUE: | |
| 88 |
1/2✓ Branch 161 → 162 taken 2 times.
✗ Branch 161 → 797 not taken.
|
4 | return "Duplicate enum item value"; |
| 89 | 2 | case GLOBAL_OF_TYPE_DYN: | |
| 90 |
1/2✓ Branch 167 → 168 taken 2 times.
✗ Branch 167 → 800 not taken.
|
4 | return "Global of type dyn"; |
| 91 | ✗ | case GLOBAL_OF_INVALID_TYPE: | |
| 92 | ✗ | return "Global of invalid type"; | |
| 93 | 2 | case GLOBAL_CONST_WITHOUT_VALUE: | |
| 94 |
1/2✓ Branch 179 → 180 taken 2 times.
✗ Branch 179 → 806 not taken.
|
4 | return "Global const without value"; |
| 95 | 8 | case MISSING_RETURN_STMT: | |
| 96 |
1/2✓ Branch 185 → 186 taken 8 times.
✗ Branch 185 → 809 not taken.
|
16 | return "Missing return statement"; |
| 97 | 12 | case INVALID_PARAM_ORDER: | |
| 98 |
1/2✓ Branch 191 → 192 taken 12 times.
✗ Branch 191 → 812 not taken.
|
24 | return "Invalid argument order"; |
| 99 | 2 | case LAMBDA_WITH_OPTIONAL_PARAMS: | |
| 100 |
1/2✓ Branch 197 → 198 taken 2 times.
✗ Branch 197 → 815 not taken.
|
4 | return "Lambda with optional parameters"; |
| 101 | 4 | case REFERENCED_OVERLOADED_FCT: | |
| 102 |
1/2✓ Branch 203 → 204 taken 4 times.
✗ Branch 203 → 818 not taken.
|
8 | return "Referenced overloaded function"; |
| 103 | 2 | case DTOR_MUST_BE_PROCEDURE: | |
| 104 |
1/2✓ Branch 209 → 210 taken 2 times.
✗ Branch 209 → 821 not taken.
|
4 | return "Destructor must be a procedure"; |
| 105 | 2 | case DTOR_WITH_PARAMS: | |
| 106 |
1/2✓ Branch 215 → 216 taken 2 times.
✗ Branch 215 → 824 not taken.
|
4 | return "Destructors must not have parameters"; |
| 107 | 64 | case OPERATOR_WRONG_DATA_TYPE: | |
| 108 |
1/2✓ Branch 221 → 222 taken 64 times.
✗ Branch 221 → 827 not taken.
|
128 | return "Wrong data type for operator"; |
| 109 | 4 | case INVALID_ITERATOR: | |
| 110 |
1/2✓ Branch 227 → 228 taken 4 times.
✗ Branch 227 → 830 not taken.
|
8 | return "Invalid iterator"; |
| 111 | 18 | case UNEXPECTED_DYN_TYPE: | |
| 112 |
1/2✓ Branch 233 → 234 taken 18 times.
✗ Branch 233 → 833 not taken.
|
36 | return "Unexpected dyn type"; |
| 113 | 28 | case REASSIGN_CONST_VARIABLE: | |
| 114 |
1/2✓ Branch 239 → 240 taken 28 times.
✗ Branch 239 → 836 not taken.
|
56 | return "Cannot re-assign constant variable"; |
| 115 | 10 | case CONDITION_MUST_BE_BOOL: | |
| 116 |
1/2✓ Branch 245 → 246 taken 10 times.
✗ Branch 245 → 839 not taken.
|
20 | return "Condition must be bool"; |
| 117 | 2 | case SWITCH_EXPR_MUST_BE_PRIMITIVE: | |
| 118 |
1/2✓ Branch 251 → 252 taken 2 times.
✗ Branch 251 → 842 not taken.
|
4 | return "Switch expression of wrong type"; |
| 119 | 4 | case SWITCH_CASE_TYPE_MISMATCH: | |
| 120 |
1/2✓ Branch 257 → 258 taken 4 times.
✗ Branch 257 → 845 not taken.
|
8 | return "Case constant type does not match switch expression type"; |
| 121 | 4 | case MISSING_MAIN_FUNCTION: | |
| 122 |
1/2✓ Branch 263 → 264 taken 4 times.
✗ Branch 263 → 848 not taken.
|
8 | return "Spice executables must contain a main function"; |
| 123 | 6 | case FCT_PARAM_IS_TYPE_DYN: | |
| 124 |
1/2✓ Branch 269 → 270 taken 6 times.
✗ Branch 269 → 851 not taken.
|
12 | return "Parameter type dyn not valid in function/procedure definition without default value"; |
| 125 | 4 | case INVALID_BREAK_NUMBER: | |
| 126 |
1/2✓ Branch 275 → 276 taken 4 times.
✗ Branch 275 → 854 not taken.
|
8 | return "Invalid number of break calls"; |
| 127 | 4 | case INVALID_CONTINUE_NUMBER: | |
| 128 |
1/2✓ Branch 281 → 282 taken 4 times.
✗ Branch 281 → 857 not taken.
|
8 | return "Invalid number of continue calls"; |
| 129 | 4 | case FALLTHROUGH_NOT_ALLOWED: | |
| 130 |
1/2✓ Branch 287 → 288 taken 4 times.
✗ Branch 287 → 860 not taken.
|
8 | return "Fallthrough statement not allowed here"; |
| 131 | 4 | case CASE_CONSTANT_INVALID_TYPE: | |
| 132 |
1/2✓ Branch 293 → 294 taken 4 times.
✗ Branch 293 → 863 not taken.
|
8 | return "Case constant of invalid type"; |
| 133 | 14 | case PRINTF_TYPE_ERROR: | |
| 134 |
1/2✓ Branch 299 → 300 taken 14 times.
✗ Branch 299 → 866 not taken.
|
28 | return "Types of printf call not matching"; |
| 135 | 4 | case PRINTF_ARG_COUNT_ERROR: | |
| 136 |
1/2✓ Branch 305 → 306 taken 4 times.
✗ Branch 305 → 869 not taken.
|
8 | return "Printf arg number not matching template string"; |
| 137 | 4 | case DUPLICATE_IMPORT_NAME: | |
| 138 |
1/2✓ Branch 311 → 312 taken 4 times.
✗ Branch 311 → 872 not taken.
|
8 | return "Duplicate import name"; |
| 139 | 4 | case IMPORTED_FILE_NOT_EXISTING: | |
| 140 |
1/2✓ Branch 317 → 318 taken 4 times.
✗ Branch 317 → 875 not taken.
|
8 | return "Imported source file not existing"; |
| 141 | 4 | case INVALID_IMPORT_PATH: | |
| 142 |
1/2✓ Branch 323 → 324 taken 4 times.
✗ Branch 323 → 878 not taken.
|
8 | return "Invalid import path"; |
| 143 | 2 | case ACCESS_TO_NON_EXISTING_MEMBER: | |
| 144 |
1/2✓ Branch 329 → 330 taken 2 times.
✗ Branch 329 → 881 not taken.
|
4 | return "Access to non-existing member"; |
| 145 | 6 | case INVALID_MEMBER_ACCESS: | |
| 146 |
1/2✓ Branch 335 → 336 taken 6 times.
✗ Branch 335 → 884 not taken.
|
12 | return "Member access is only allowed on structs and Strings"; |
| 147 | ✗ | case SCOPE_ACCESS_ONLY_IMPORTS: | |
| 148 | ✗ | return "Scope access is only allowed on imports"; | |
| 149 | 8 | case UNKNOWN_DATATYPE: | |
| 150 |
1/2✓ Branch 347 → 348 taken 8 times.
✗ Branch 347 → 890 not taken.
|
16 | return "Unknown datatype"; |
| 151 | 2 | case UNKNOWN_ATTR: | |
| 152 |
1/2✓ Branch 353 → 354 taken 2 times.
✗ Branch 353 → 893 not taken.
|
4 | return "Unknown attribute"; |
| 153 | 2 | case INVALID_ATTR_TARGET: | |
| 154 |
1/2✓ Branch 359 → 360 taken 2 times.
✗ Branch 359 → 896 not taken.
|
4 | return "Invalid attribute target"; |
| 155 | ✗ | case INVALID_ATTR_VALUE: | |
| 156 | ✗ | return "Invalid attribute value"; | |
| 157 | 2 | case MISSING_ATTR_VALUE: | |
| 158 |
1/2✓ Branch 371 → 372 taken 2 times.
✗ Branch 371 → 902 not taken.
|
4 | return "Missing attribute value"; |
| 159 | 4 | case NUMBER_OF_FIELDS_NOT_MATCHING: | |
| 160 |
1/2✓ Branch 377 → 378 taken 4 times.
✗ Branch 377 → 905 not taken.
|
8 | return "Number of struct fields not matching declaration"; |
| 161 | 2 | case FIELD_TYPE_NOT_MATCHING: | |
| 162 |
1/2✓ Branch 383 → 384 taken 2 times.
✗ Branch 383 → 908 not taken.
|
4 | return "The type of a field value does not match the declaration"; |
| 163 | 4 | case ARRAY_SIZE_INVALID: | |
| 164 |
1/2✓ Branch 389 → 390 taken 4 times.
✗ Branch 389 → 911 not taken.
|
8 | return "Array size invalid"; |
| 165 | 2 | case FOREACH_IDX_NOT_LONG: | |
| 166 |
1/2✓ Branch 395 → 396 taken 2 times.
✗ Branch 395 → 914 not taken.
|
4 | return "Foreach index not of type long"; |
| 167 | 2 | case ARRAY_INDEX_NOT_INT_OR_LONG: | |
| 168 |
1/2✓ Branch 401 → 402 taken 2 times.
✗ Branch 401 → 917 not taken.
|
4 | return "Array index not of type int or long"; |
| 169 | 2 | case ARRAY_ITEM_TYPE_NOT_MATCHING: | |
| 170 |
1/2✓ Branch 407 → 408 taken 2 times.
✗ Branch 407 → 920 not taken.
|
4 | return "Array item type not matching"; |
| 171 | 2 | case EXPECTED_ARRAY_TYPE: | |
| 172 |
1/2✓ Branch 413 → 414 taken 2 times.
✗ Branch 413 → 923 not taken.
|
4 | return "Expected array type"; |
| 173 | 2 | case EXPECTED_ERROR_TYPE: | |
| 174 |
1/2✓ Branch 419 → 420 taken 2 times.
✗ Branch 419 → 926 not taken.
|
4 | return "Expected error type"; |
| 175 | 2 | case INVALID_SYSCALL_NUMBER_TYPE: | |
| 176 |
1/2✓ Branch 425 → 426 taken 2 times.
✗ Branch 425 → 929 not taken.
|
4 | return "Invalid syscall number type"; |
| 177 | 4 | case SYSCALL_NUMBER_OUT_OF_RANGE: | |
| 178 |
1/2✓ Branch 431 → 432 taken 4 times.
✗ Branch 431 → 932 not taken.
|
8 | return "Syscall number out of range"; |
| 179 | ✗ | case TOO_MANY_SYSCALL_ARGS: | |
| 180 | ✗ | return "Too many syscall args"; | |
| 181 | 24 | case BUILTIN_TEMPLATE_TYPE_COUNT_MISMATCH: | |
| 182 |
1/2✓ Branch 443 → 444 taken 24 times.
✗ Branch 443 → 938 not taken.
|
48 | return "Builtin function template type count mismatch"; |
| 183 | 30 | case BUILTIN_ARG_COUNT_MISMATCH: | |
| 184 |
1/2✓ Branch 449 → 450 taken 30 times.
✗ Branch 449 → 941 not taken.
|
60 | return "Builtin function argument count mismatch"; |
| 185 | 18 | case BUILTIN_SIGNATURE_MISMATCH: | |
| 186 |
1/2✓ Branch 455 → 456 taken 18 times.
✗ Branch 455 → 944 not taken.
|
36 | return "Builtin function signature mismatch"; |
| 187 | 16 | case BUILTIN_ARG_TYPE_MISMATCH: | |
| 188 |
1/2✓ Branch 461 → 462 taken 16 times.
✗ Branch 461 → 947 not taken.
|
32 | return "Builtin function argument type mismatch"; |
| 189 | 4 | case RETURN_WITHOUT_VALUE_RESULT: | |
| 190 |
1/2✓ Branch 467 → 468 taken 4 times.
✗ Branch 467 → 950 not taken.
|
8 | return "Return without initialization of result variable"; |
| 191 | 4 | case RETURN_WITH_VALUE_IN_PROCEDURE: | |
| 192 |
1/2✓ Branch 473 → 474 taken 4 times.
✗ Branch 473 → 953 not taken.
|
8 | return "Return with value in procedure"; |
| 193 | 2 | case RETURN_OF_TEMPORARY_VALUE: | |
| 194 |
1/2✓ Branch 479 → 480 taken 2 times.
✗ Branch 479 → 956 not taken.
|
4 | return "Return of temporary value"; |
| 195 | 2 | case INVALID_STRUCT_INSTANTIATION: | |
| 196 |
1/2✓ Branch 485 → 486 taken 2 times.
✗ Branch 485 → 959 not taken.
|
4 | return "Invalid struct instantiation"; |
| 197 | 4 | case DYN_POINTERS_NOT_ALLOWED: | |
| 198 |
1/2✓ Branch 491 → 492 taken 4 times.
✗ Branch 491 → 962 not taken.
|
8 | return "Dyn pointers not allowed"; |
| 199 | ✗ | case REF_POINTERS_ARE_NOT_ALLOWED: | |
| 200 | ✗ | return "Ref pointers not allowed"; | |
| 201 | ✗ | case DYN_REFERENCES_NOT_ALLOWED: | |
| 202 | ✗ | return "Dyn references not allowed"; | |
| 203 | ✗ | case MULTI_REF_NOT_ALLOWED: | |
| 204 | ✗ | return "Multi references not allowed"; | |
| 205 | 2 | case DYN_ARRAYS_NOT_ALLOWED: | |
| 206 |
1/2✓ Branch 515 → 516 taken 2 times.
✗ Branch 515 → 974 not taken.
|
4 | return "Dyn arrays not allowed"; |
| 207 | 2 | case REFERENCE_WITHOUT_INITIALIZER: | |
| 208 |
1/2✓ Branch 521 → 522 taken 2 times.
✗ Branch 521 → 977 not taken.
|
4 | return "Reference without initializer"; |
| 209 | 6 | case TEMP_TO_NON_CONST_REF: | |
| 210 |
1/2✓ Branch 527 → 528 taken 6 times.
✗ Branch 527 → 980 not taken.
|
12 | return "Temporary bound to non-const reference"; |
| 211 | 16 | case GENERIC_TYPE_NOT_IN_TEMPLATE: | |
| 212 |
1/2✓ Branch 533 → 534 taken 16 times.
✗ Branch 533 → 983 not taken.
|
32 | return "Generic type not contained in template"; |
| 213 | 6 | case QUALIFIER_AT_ILLEGAL_CONTEXT: | |
| 214 |
1/2✓ Branch 539 → 540 taken 6 times.
✗ Branch 539 → 986 not taken.
|
12 | return "Qualifier at illegal context"; |
| 215 | 12 | case INSUFFICIENT_VISIBILITY: | |
| 216 |
1/2✓ Branch 545 → 546 taken 12 times.
✗ Branch 545 → 989 not taken.
|
24 | return "Insufficient symbol visibility"; |
| 217 | ✗ | case JOIN_ARG_MUST_BE_TID: | |
| 218 | ✗ | return "Argument of join builtin must be a tid"; | |
| 219 | 6 | case EXPECTED_GENERIC_TYPE: | |
| 220 |
1/2✓ Branch 557 → 558 taken 6 times.
✗ Branch 557 → 995 not taken.
|
12 | return "Expected a generic type"; |
| 221 | ✗ | case EXPECTED_NON_GENERIC_TYPE: | |
| 222 | ✗ | return "Expected a non-generic type"; | |
| 223 | 2 | case EXPECTED_STRUCT_TYPE: | |
| 224 |
1/2✓ Branch 569 → 570 taken 2 times.
✗ Branch 569 → 1001 not taken.
|
4 | return "Expected a struct type"; |
| 225 | ✗ | case EXPECTED_INTERFACE_TYPE: | |
| 226 | ✗ | return "Expected an interface type"; | |
| 227 | 4 | case EXPECTED_COMPILE_TIME_VALUE: | |
| 228 |
1/2✓ Branch 581 → 582 taken 4 times.
✗ Branch 581 → 1007 not taken.
|
8 | return "Expected compile time value"; |
| 229 | ✗ | case ALIAS_WITH_TEMPLATE_LIST: | |
| 230 | ✗ | return "Alias with template list"; | |
| 231 | ✗ | case INTERFACE_WITH_TEMPLATE_LIST: | |
| 232 | ✗ | return "Interface reference with template list"; | |
| 233 | 4 | case INVALID_TEMPLATE_TYPES: | |
| 234 |
1/2✓ Branch 599 → 600 taken 4 times.
✗ Branch 599 → 1016 not taken.
|
8 | return "Invalid template types"; |
| 235 | ✗ | case EXPECTED_VALUE: | |
| 236 | ✗ | return "Expected value"; | |
| 237 | ✗ | case EXPECTED_TYPE: | |
| 238 | ✗ | return "Expected type"; | |
| 239 | 6 | case UNSAFE_OPERATION_IN_SAFE_CONTEXT: | |
| 240 |
1/2✓ Branch 617 → 618 taken 6 times.
✗ Branch 617 → 1025 not taken.
|
12 | return "Unsafe operation in safe context"; |
| 241 | 2 | case ASSERTION_CONDITION_BOOL: | |
| 242 |
1/2✓ Branch 623 → 624 taken 2 times.
✗ Branch 623 → 1028 not taken.
|
4 | return "Assertion condition must be bool"; |
| 243 | 2 | case ARRAY_INDEX_OUT_OF_BOUNDS: | |
| 244 |
1/2✓ Branch 629 → 630 taken 2 times.
✗ Branch 629 → 1031 not taken.
|
4 | return "Array index out of bounds"; |
| 245 | 2 | case EXPECTED_CONST_VARIABLE: | |
| 246 |
1/2✓ Branch 635 → 636 taken 2 times.
✗ Branch 635 → 1034 not taken.
|
4 | return "Expected const variable"; |
| 247 | 4 | case DIVISION_BY_ZERO: | |
| 248 |
1/2✓ Branch 641 → 642 taken 4 times.
✗ Branch 641 → 1037 not taken.
|
8 | return "Division by zero"; |
| 249 | 2 | case TEST_FUNCTION_WITH_PARAMS: | |
| 250 |
1/2✓ Branch 647 → 648 taken 2 times.
✗ Branch 647 → 1040 not taken.
|
4 | return "Test function with parameters"; |
| 251 | 2 | case TEST_FUNCTION_WRONG_RETURN_TYPE: | |
| 252 |
1/2✓ Branch 653 → 654 taken 2 times.
✗ Branch 653 → 1043 not taken.
|
4 | return "Test function with wrong return type"; |
| 253 | 4 | case LAMBDA_CAPTURE_ESCAPE: | |
| 254 |
1/2✓ Branch 659 → 660 taken 4 times.
✗ Branch 659 → 1046 not taken.
|
8 | return "Lambda may outlive its captures"; |
| 255 | 2 | case ERR_PROPAGATION_INVALID_OPERAND: | |
| 256 |
1/2✓ Branch 665 → 666 taken 2 times.
✗ Branch 665 → 1049 not taken.
|
4 | return "Invalid operand for error propagation operator"; |
| 257 | 2 | case ERR_PROPAGATION_INVALID_CONTEXT: | |
| 258 |
1/2✓ Branch 671 → 672 taken 2 times.
✗ Branch 671 → 1052 not taken.
|
4 | return "Error propagation operator used in invalid context"; |
| 259 | 4 | case DISCARDED_RESULT_VALUE: | |
| 260 |
1/2✓ Branch 677 → 678 taken 4 times.
✗ Branch 677 → 1055 not taken.
|
8 | return "Discarded Result value"; |
| 261 | ✗ | case UNION_AMBIGUITY: | |
| 262 | ✗ | return "Union ambiguity"; | |
| 263 | 4 | case UNION_INFINITE_SIZE: | |
| 264 |
1/2✓ Branch 689 → 690 taken 4 times.
✗ Branch 689 → 1061 not taken.
|
8 | return "Union with infinite size detected"; |
| 265 | 2 | case UNION_FIELD_TYPE_NOT_TRIVIAL: | |
| 266 |
1/2✓ Branch 695 → 696 taken 2 times.
✗ Branch 695 → 1064 not taken.
|
4 | return "Union field type not trivial"; |
| 267 | 2 | case UNION_FIELD_MUST_NOT_BE_REFERENCE: | |
| 268 |
1/2✓ Branch 701 → 702 taken 2 times.
✗ Branch 701 → 1067 not taken.
|
4 | return "Union field must not be a reference"; |
| 269 | 2 | case DUPLICATE_UNION_DEFAULT_VALUE: | |
| 270 |
1/2✓ Branch 707 → 708 taken 2 times.
✗ Branch 707 → 1070 not taken.
|
4 | return "Duplicate default value in union"; |
| 271 | 10 | case AMBIGUOUS_SYMBOL: | |
| 272 |
1/2✓ Branch 713 → 714 taken 10 times.
✗ Branch 713 → 1073 not taken.
|
20 | return "Ambiguous symbol"; |
| 273 | } | ||
| 274 | − | assert_fail("Unknown error"); // GCOV_EXCL_LINE | |
| 275 | return "Unknown error"; // GCOV_EXCL_LINE | ||
| 276 | } | ||
| 277 | |||
| 278 | } // namespace spice::compiler | ||
| 279 |