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