GCC Code Coverage Report


src/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
127 / 133, 1 excl
95.5%
Branches:
110 / 119, 4 excl
92.4%
Functions:
6 / 6
100.0%

exception/semantic-error.spice
Line Branch Exec Source
1 // Copyright (c) 2021-2026 ChilliBits. All rights reserved.
2
3 // Std imports
4 import "std/text/stringstream";
5
6 // Own imports
7 import "@/exception/fatal-error";
8 import "@/ast/ast-nodes";
9
10 public type SemanticErrorType enum {
11 REFERENCED_UNDEFINED_FUNCTION,
12 REFERENCED_UNDEFINED_VARIABLE,
13 REFERENCED_UNDEFINED_STRUCT,
14 REFERENCED_UNDEFINED_INTERFACE,
15 REFERENCED_UNDEFINED_UNION,
16 REFERENCED_UNDEFINED_FIELD,
17 USED_BEFORE_DECLARED,
18 FUNCTION_AMBIGUITY,
19 STRUCT_AMBIGUITY,
20 INTERFACE_AMBIGUITY,
21 DUPLICATE_SYMBOL,
22 VARIABLE_DECLARED_TWICE,
23 EXPORTED_SYMBOL_COLLISION,
24 FUNCTION_DECLARED_TWICE,
25 PROCEDURE_DECLARED_TWICE,
26 STRUCT_INFINITE_SIZE,
27 NO_MATCHING_CTOR_FOUND,
28 COPY_CTOR_REQUIRED,
29 INTERFACE_METHOD_NOT_IMPLEMENTED,
30 INVALID_DEFAULT_METHOD,
31 INVALID_SYMBOL_ACCESS,
32 DUPLICATE_ENUM_ITEM_VALUE,
33 GLOBAL_OF_TYPE_DYN,
34 GLOBAL_OF_INVALID_TYPE,
35 GLOBAL_CONST_WITHOUT_VALUE,
36 MISSING_RETURN_STMT,
37 INVALID_PARAM_ORDER,
38 LAMBDA_WITH_OPTIONAL_PARAMS,
39 REFERENCED_OVERLOADED_FCT,
40 DTOR_MUST_BE_PROCEDURE,
41 DTOR_WITH_PARAMS,
42 OPERATOR_WRONG_DATA_TYPE,
43 INVALID_ITERATOR,
44 UNEXPECTED_DYN_TYPE,
45 REASSIGN_CONST_VARIABLE,
46 CONDITION_MUST_BE_BOOL,
47 SWITCH_EXPR_MUST_BE_PRIMITIVE,
48 SWITCH_CASE_TYPE_MISMATCH,
49 MISSING_MAIN_FUNCTION,
50 FCT_PARAM_IS_TYPE_DYN,
51 INVALID_BREAK_NUMBER,
52 INVALID_CONTINUE_NUMBER,
53 FALLTHROUGH_NOT_ALLOWED,
54 CASE_CONSTANT_INVALID_TYPE,
55 PRINTF_TYPE_ERROR,
56 PRINTF_ARG_COUNT_ERROR,
57 DUPLICATE_IMPORT_NAME,
58 IMPORTED_FILE_NOT_EXISTING,
59 INVALID_IMPORT_PATH,
60 ACCESS_TO_NON_EXISTING_MEMBER,
61 INVALID_MEMBER_ACCESS,
62 UNKNOWN_DATATYPE,
63 UNKNOWN_ATTR,
64 INVALID_ATTR_TARGET,
65 MISSING_ATTR_VALUE,
66 UNSUPPORTED_ATTR_VALUE,
67 NUMBER_OF_FIELDS_NOT_MATCHING,
68 FIELD_TYPE_NOT_MATCHING,
69 ARRAY_SIZE_INVALID,
70 FOREACH_IDX_NOT_LONG,
71 ARRAY_INDEX_NOT_INT_OR_LONG,
72 ARRAY_ITEM_TYPE_NOT_MATCHING,
73 EXPECTED_ARRAY_TYPE,
74 EXPECTED_ERROR_TYPE,
75 INVALID_SYSCALL_NUMBER_TYPE,
76 SYSCALL_NUMBER_OUT_OF_RANGE,
77 BUILTIN_TEMPLATE_TYPE_COUNT_MISMATCH,
78 BUILTIN_ARG_COUNT_MISMATCH,
79 BUILTIN_SIGNATURE_MISMATCH,
80 BUILTIN_ARG_TYPE_MISMATCH,
81 RETURN_WITHOUT_VALUE_RESULT,
82 RETURN_WITH_VALUE_IN_PROCEDURE,
83 RETURN_OF_TEMPORARY_VALUE,
84 INVALID_STRUCT_INSTANTIATION,
85 DYN_POINTERS_NOT_ALLOWED,
86 REF_POINTERS_ARE_NOT_ALLOWED,
87 DYN_REFERENCES_NOT_ALLOWED,
88 MULTI_REF_NOT_ALLOWED,
89 DYN_ARRAYS_NOT_ALLOWED,
90 REFERENCE_WITHOUT_INITIALIZER,
91 TEMP_TO_NON_CONST_REF,
92 GENERIC_TYPE_NOT_IN_TEMPLATE,
93 QUALIFIER_AT_ILLEGAL_CONTEXT,
94 INSUFFICIENT_VISIBILITY,
95 EXPECTED_GENERIC_TYPE,
96 EXPECTED_NON_GENERIC_TYPE,
97 EXPECTED_STRUCT_TYPE,
98 EXPECTED_INTERFACE_TYPE,
99 EXPECTED_COMPILE_TIME_VALUE,
100 ALIAS_WITH_TEMPLATE_LIST,
101 INVALID_TEMPLATE_TYPES,
102 EXPECTED_TYPE,
103 UNSAFE_OPERATION_IN_SAFE_CONTEXT,
104 ASSERTION_CONDITION_BOOL,
105 ARRAY_INDEX_OUT_OF_BOUNDS,
106 EXPECTED_CONST_VARIABLE,
107 DIVISION_BY_ZERO,
108 TEST_FUNCTION_WITH_PARAMS,
109 TEST_FUNCTION_WRONG_RETURN_TYPE,
110 LAMBDA_CAPTURE_ESCAPE,
111 ERR_PROPAGATION_INVALID_OPERAND,
112 ERR_PROPAGATION_INVALID_CONTEXT,
113 DISCARDED_RESULT_VALUE,
114 UNION_AMBIGUITY,
115 UNION_INFINITE_SIZE,
116 UNION_FIELD_TYPE_NOT_TRIVIAL,
117 UNION_FIELD_MUST_NOT_BE_REFERENCE,
118 DUPLICATE_UNION_DEFAULT_VALUE,
119 AMBIGUOUS_SYMBOL,
120 INTERFACE_RETURNED_BY_VALUE
121 }
122
123 359 public type SemanticError struct {
124 String errorMessage
125 }
126
127 368 public p SemanticError.ctor(const ASTNode* node, const SemanticErrorType errorType, const string message, bool printErrorMessage = true) {
128 368 assert node != nil<ASTNode*>;
129 368 StringStream msg;
130 368 msg << "[Error|Semantic] " << node.codeLoc.toPrettyString() << ":" << endl();
131 368 msg << this.getMessagePrefix(errorType) << ": " << message;
132
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 284 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 82 times.
368 if printErrorMessage {
133 // Nodes without a source interval (not created by the parser) have no snippet
134 366 const String nodeErrorMessage = node.getErrorMessage();
135
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 284 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 82 times.
366 if !nodeErrorMessage.isEmpty() {
136 366 msg << "\n\n" << nodeErrorMessage;
137 366 }
138 366 }
139 368 this.errorMessage = msg.str();
140 368 }
141
142 /**
143 * Abort the compilation with a semantic error right away. This is meant for places, that cannot continue after the error (e.g. because they have to return a valid type). Places that can
144 * continue should record the error with throwSemanticError (see ErrorManager) instead, which keeps them testable.
145 *
146 * @param node AST node, where the error occurred
147 * @param errorType Type of the error
148 * @param message Error message suffix
149 */
150 9 public p abortWithSemanticError(const ASTNode* node, const SemanticErrorType errorType, const string message) {
151 9 const SemanticError error = SemanticError(node, errorType, message);
152 9 abortWithError(error.getMessage());
153 9 }
154
155 /**
156 * Get the message for this particular error instance
157 *
158 * @return Error message
159 */
160 368 public f<const String&> SemanticError.getMessage() {
161 368 return this.errorMessage;
162 }
163
164 /**
165 * Get the prefix of the error message for a particular error
166 *
167 * @param type Type of the error
168 * @return Prefix string for the error type
169 */
170 368 f<string> SemanticError.getMessagePrefix(const SemanticErrorType errorType) {
171
105/111
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 5 times.
✓ Branch 13 taken 2 times.
✓ Branch 14 taken 1 time.
✓ Branch 15 taken 2 times.
✓ Branch 16 taken 8 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 8 times.
✓ Branch 19 taken 4 times.
✓ Branch 20 taken 1 time.
✓ Branch 21 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 23 taken 1 time.
✓ Branch 24 taken 1 time.
✓ Branch 25 taken 4 times.
✓ Branch 26 taken 6 times.
✓ Branch 27 taken 1 time.
✓ Branch 28 taken 2 times.
✓ Branch 29 taken 1 time.
✓ Branch 30 taken 1 time.
✓ Branch 31 taken 33 times.
✓ Branch 32 taken 2 times.
✓ Branch 33 taken 11 times.
✓ Branch 34 taken 20 times.
✓ Branch 35 taken 5 times.
✓ Branch 36 taken 1 time.
✓ Branch 37 taken 2 times.
✓ Branch 38 taken 2 times.
✓ Branch 39 taken 3 times.
✓ Branch 40 taken 2 times.
✓ Branch 41 taken 2 times.
✓ Branch 42 taken 4 times.
✓ Branch 43 taken 2 times.
✓ Branch 44 taken 8 times.
✓ Branch 45 taken 2 times.
✓ Branch 46 taken 2 times.
✓ Branch 47 taken 3 times.
✓ Branch 48 taken 2 times.
✓ Branch 49 taken 1 time.
✓ Branch 50 taken 6 times.
✓ Branch 51 taken 5 times.
✓ Branch 52 taken 1 time.
✓ Branch 53 taken 1 time.
✓ Branch 54 taken 1 time.
✓ Branch 55 taken 1 time.
✓ Branch 56 taken 2 times.
✓ Branch 57 taken 1 time.
✓ Branch 58 taken 3 times.
✓ Branch 59 taken 1 time.
✓ Branch 60 taken 1 time.
✓ Branch 61 taken 1 time.
✓ Branch 62 taken 1 time.
✓ Branch 63 taken 1 time.
✓ Branch 64 taken 1 time.
✓ Branch 65 taken 2 times.
✓ Branch 66 taken 12 times.
✓ Branch 67 taken 15 times.
✓ Branch 68 taken 9 times.
✓ Branch 69 taken 8 times.
✓ Branch 70 taken 2 times.
✓ Branch 71 taken 3 times.
✓ Branch 72 taken 1 time.
✓ Branch 73 taken 1 time.
✓ Branch 74 taken 2 times.
✓ Branch 75 taken 1 time.
✓ Branch 76 taken 1 time.
✓ Branch 77 taken 1 time.
✓ Branch 78 taken 1 time.
✓ Branch 79 taken 2 times.
✓ Branch 80 taken 3 times.
✓ Branch 81 taken 10 times.
✓ Branch 82 taken 3 times.
✓ Branch 83 taken 6 times.
✓ Branch 84 taken 3 times.
✓ Branch 85 taken 2 times.
✓ Branch 86 taken 1 time.
✓ Branch 87 taken 1 time.
✓ Branch 88 taken 2 times.
✓ Branch 89 taken 2 times.
✓ Branch 90 taken 2 times.
✓ Branch 91 taken 2 times.
✓ Branch 92 taken 4 times.
✓ Branch 93 taken 1 time.
✓ Branch 94 taken 1 time.
✓ Branch 95 taken 1 time.
✓ Branch 96 taken 2 times.
✓ Branch 97 taken 1 time.
✓ Branch 98 taken 1 time.
✓ Branch 99 taken 2 times.
✓ Branch 100 taken 1 time.
✓ Branch 101 taken 2 times.
✓ Branch 102 taken 2 times.
✗ Branch 103 not taken.
✓ Branch 104 taken 2 times.
✓ Branch 105 taken 1 time.
✓ Branch 106 taken 1 time.
✓ Branch 107 taken 1 time.
✓ Branch 108 taken 5 times.
✗ Branch 109 not taken.
✓ Branch 110 taken 4 times.
368 switch errorType {
172 24 case SemanticErrorType::REFERENCED_UNDEFINED_FUNCTION: { return "Referenced undefined function"; }
173 7 case SemanticErrorType::REFERENCED_UNDEFINED_VARIABLE: { return "Referenced undefined variable"; }
174 5 case SemanticErrorType::REFERENCED_UNDEFINED_STRUCT: { return "Referenced undefined struct"; }
175 1 case SemanticErrorType::REFERENCED_UNDEFINED_INTERFACE: { return "Referenced undefined interface"; }
176 1 case SemanticErrorType::REFERENCED_UNDEFINED_UNION: { return "Referenced undefined union"; }
177 ✗ case SemanticErrorType::REFERENCED_UNDEFINED_FIELD: { return "Referenced undefined struct field"; }
178 2 case SemanticErrorType::USED_BEFORE_DECLARED: { return "Used before declared"; }
179 1 case SemanticErrorType::FUNCTION_AMBIGUITY: { return "Function ambiguity"; }
180 ✗ case SemanticErrorType::STRUCT_AMBIGUITY: { return "Struct ambiguity"; }
181 ✗ case SemanticErrorType::INTERFACE_AMBIGUITY: { return "Interface ambiguity"; }
182 7 case SemanticErrorType::DUPLICATE_SYMBOL: { return "Duplicate symbol"; }
183 6 case SemanticErrorType::VARIABLE_DECLARED_TWICE: { return "Multiple declarations of the same variable"; }
184 5 case SemanticErrorType::EXPORTED_SYMBOL_COLLISION: { return "Multiple exported symbols with the same linker name"; }
185 2 case SemanticErrorType::FUNCTION_DECLARED_TWICE: { return "Multiple declarations of a function"; }
186 1 case SemanticErrorType::PROCEDURE_DECLARED_TWICE: { return "Multiple declarations of a procedure"; }
187 2 case SemanticErrorType::STRUCT_INFINITE_SIZE: { return "Struct with infinite size"; }
188 8 case SemanticErrorType::NO_MATCHING_CTOR_FOUND: { return "No matching ctor found"; }
189 ✗ case SemanticErrorType::COPY_CTOR_REQUIRED: { return "Missing mandatory copy ctor"; }
190 8 case SemanticErrorType::INTERFACE_METHOD_NOT_IMPLEMENTED: { return "Interface method not implemented"; }
191 4 case SemanticErrorType::INVALID_DEFAULT_METHOD: { return "Invalid default method"; }
192 1 case SemanticErrorType::INVALID_SYMBOL_ACCESS: { return "Invalid symbol access"; }
193 1 case SemanticErrorType::DUPLICATE_ENUM_ITEM_VALUE: { return "Duplicate enum item value"; }
194 1 case SemanticErrorType::GLOBAL_OF_TYPE_DYN: { return "Global of type dyn"; }
195 1 case SemanticErrorType::GLOBAL_OF_INVALID_TYPE: { return "Global of invalid type"; }
196 1 case SemanticErrorType::GLOBAL_CONST_WITHOUT_VALUE: { return "Global const without value"; }
197 4 case SemanticErrorType::MISSING_RETURN_STMT: { return "Missing return statement"; }
198 6 case SemanticErrorType::INVALID_PARAM_ORDER: { return "Invalid argument order"; }
199 1 case SemanticErrorType::LAMBDA_WITH_OPTIONAL_PARAMS: { return "Lambda with optional parameters"; }
200 2 case SemanticErrorType::REFERENCED_OVERLOADED_FCT: { return "Referenced overloaded function"; }
201 1 case SemanticErrorType::DTOR_MUST_BE_PROCEDURE: { return "Destructor must be a procedure"; }
202 1 case SemanticErrorType::DTOR_WITH_PARAMS: { return "Destructors must not have parameters"; }
203 33 case SemanticErrorType::OPERATOR_WRONG_DATA_TYPE: { return "Wrong data type for operator"; }
204 2 case SemanticErrorType::INVALID_ITERATOR: { return "Invalid iterator"; }
205 11 case SemanticErrorType::UNEXPECTED_DYN_TYPE: { return "Unexpected dyn type"; }
206 20 case SemanticErrorType::REASSIGN_CONST_VARIABLE: { return "Cannot re-assign constant variable"; }
207 5 case SemanticErrorType::CONDITION_MUST_BE_BOOL: { return "Condition must be bool"; }
208 1 case SemanticErrorType::SWITCH_EXPR_MUST_BE_PRIMITIVE: { return "Switch expression of wrong type"; }
209 2 case SemanticErrorType::SWITCH_CASE_TYPE_MISMATCH: { return "Case constant type does not match switch expression type"; }
210 2 case SemanticErrorType::MISSING_MAIN_FUNCTION: { return "Spice executables must contain a main function"; }
211 3 case SemanticErrorType::FCT_PARAM_IS_TYPE_DYN: { return "Parameter type dyn not valid in function/procedure definition without default value"; }
212 2 case SemanticErrorType::INVALID_BREAK_NUMBER: { return "Invalid number of break calls"; }
213 2 case SemanticErrorType::INVALID_CONTINUE_NUMBER: { return "Invalid number of continue calls"; }
214 4 case SemanticErrorType::FALLTHROUGH_NOT_ALLOWED: { return "Fallthrough statement not allowed here"; }
215 2 case SemanticErrorType::CASE_CONSTANT_INVALID_TYPE: { return "Case constant of invalid type"; }
216 8 case SemanticErrorType::PRINTF_TYPE_ERROR: { return "Types of printf call not matching"; }
217 2 case SemanticErrorType::PRINTF_ARG_COUNT_ERROR: { return "Printf arg number not matching template string"; }
218 2 case SemanticErrorType::DUPLICATE_IMPORT_NAME: { return "Duplicate import name"; }
219 3 case SemanticErrorType::IMPORTED_FILE_NOT_EXISTING: { return "Imported source file not existing"; }
220 2 case SemanticErrorType::INVALID_IMPORT_PATH: { return "Invalid import path"; }
221 1 case SemanticErrorType::ACCESS_TO_NON_EXISTING_MEMBER: { return "Access to non-existing member"; }
222 6 case SemanticErrorType::INVALID_MEMBER_ACCESS: { return "Member access is only allowed on structs and Strings"; }
223 5 case SemanticErrorType::UNKNOWN_DATATYPE: { return "Unknown datatype"; }
224 1 case SemanticErrorType::UNKNOWN_ATTR: { return "Unknown attribute"; }
225 1 case SemanticErrorType::INVALID_ATTR_TARGET: { return "Invalid attribute target"; }
226 1 case SemanticErrorType::MISSING_ATTR_VALUE: { return "Missing attribute value"; }
227 1 case SemanticErrorType::UNSUPPORTED_ATTR_VALUE: { return "Unsupported attribute value"; }
228 2 case SemanticErrorType::NUMBER_OF_FIELDS_NOT_MATCHING: { return "Number of struct fields not matching declaration"; }
229 1 case SemanticErrorType::FIELD_TYPE_NOT_MATCHING: { return "The type of a field value does not match the declaration"; }
230 3 case SemanticErrorType::ARRAY_SIZE_INVALID: { return "Array size invalid"; }
231 1 case SemanticErrorType::FOREACH_IDX_NOT_LONG: { return "Foreach index not of type long"; }
232 1 case SemanticErrorType::ARRAY_INDEX_NOT_INT_OR_LONG: { return "Array index not of type int or long"; }
233 1 case SemanticErrorType::ARRAY_ITEM_TYPE_NOT_MATCHING: { return "Array item type not matching"; }
234 1 case SemanticErrorType::EXPECTED_ARRAY_TYPE: { return "Expected array type"; }
235 1 case SemanticErrorType::EXPECTED_ERROR_TYPE: { return "Expected error type"; }
236 1 case SemanticErrorType::INVALID_SYSCALL_NUMBER_TYPE: { return "Invalid syscall number type"; }
237 2 case SemanticErrorType::SYSCALL_NUMBER_OUT_OF_RANGE: { return "Syscall number out of range"; }
238 12 case SemanticErrorType::BUILTIN_TEMPLATE_TYPE_COUNT_MISMATCH: { return "Builtin function template type count mismatch"; }
239 15 case SemanticErrorType::BUILTIN_ARG_COUNT_MISMATCH: { return "Builtin function argument count mismatch"; }
240 9 case SemanticErrorType::BUILTIN_SIGNATURE_MISMATCH: { return "Builtin function signature mismatch"; }
241 8 case SemanticErrorType::BUILTIN_ARG_TYPE_MISMATCH: { return "Builtin function argument type mismatch"; }
242 2 case SemanticErrorType::RETURN_WITHOUT_VALUE_RESULT: { return "Return without initialization of result variable"; }
243 3 case SemanticErrorType::RETURN_WITH_VALUE_IN_PROCEDURE: { return "Return with value in procedure"; }
244 1 case SemanticErrorType::RETURN_OF_TEMPORARY_VALUE: { return "Return of temporary value"; }
245 1 case SemanticErrorType::INVALID_STRUCT_INSTANTIATION: { return "Invalid struct instantiation"; }
246 2 case SemanticErrorType::DYN_POINTERS_NOT_ALLOWED: { return "Dyn pointers not allowed"; }
247 1 case SemanticErrorType::REF_POINTERS_ARE_NOT_ALLOWED: { return "Ref pointers not allowed"; }
248 1 case SemanticErrorType::DYN_REFERENCES_NOT_ALLOWED: { return "Dyn references not allowed"; }
249 1 case SemanticErrorType::MULTI_REF_NOT_ALLOWED: { return "Multi references not allowed"; }
250 1 case SemanticErrorType::DYN_ARRAYS_NOT_ALLOWED: { return "Dyn arrays not allowed"; }
251 2 case SemanticErrorType::REFERENCE_WITHOUT_INITIALIZER: { return "Reference without initializer"; }
252 3 case SemanticErrorType::TEMP_TO_NON_CONST_REF: { return "Temporary bound to non-const reference"; }
253 10 case SemanticErrorType::GENERIC_TYPE_NOT_IN_TEMPLATE: { return "Generic type not contained in template"; }
254 3 case SemanticErrorType::QUALIFIER_AT_ILLEGAL_CONTEXT: { return "Qualifier at illegal context"; }
255 6 case SemanticErrorType::INSUFFICIENT_VISIBILITY: { return "Insufficient symbol visibility"; }
256 3 case SemanticErrorType::EXPECTED_GENERIC_TYPE: { return "Expected a generic type"; }
257 2 case SemanticErrorType::EXPECTED_NON_GENERIC_TYPE: { return "Expected a non-generic type"; }
258 1 case SemanticErrorType::EXPECTED_STRUCT_TYPE: { return "Expected a struct type"; }
259 1 case SemanticErrorType::EXPECTED_INTERFACE_TYPE: { return "Expected an interface type"; }
260 2 case SemanticErrorType::EXPECTED_COMPILE_TIME_VALUE: { return "Expected compile time value"; }
261 2 case SemanticErrorType::ALIAS_WITH_TEMPLATE_LIST: { return "Alias with template list"; }
262 2 case SemanticErrorType::INVALID_TEMPLATE_TYPES: { return "Invalid template types"; }
263 2 case SemanticErrorType::EXPECTED_TYPE: { return "Expected type"; }
264 4 case SemanticErrorType::UNSAFE_OPERATION_IN_SAFE_CONTEXT: { return "Unsafe operation in safe context"; }
265 1 case SemanticErrorType::ASSERTION_CONDITION_BOOL: { return "Assertion condition must be bool"; }
266 1 case SemanticErrorType::ARRAY_INDEX_OUT_OF_BOUNDS: { return "Array index out of bounds"; }
267 1 case SemanticErrorType::EXPECTED_CONST_VARIABLE: { return "Expected const variable"; }
268 2 case SemanticErrorType::DIVISION_BY_ZERO: { return "Division by zero"; }
269 1 case SemanticErrorType::TEST_FUNCTION_WITH_PARAMS: { return "Test function with parameters"; }
270 1 case SemanticErrorType::TEST_FUNCTION_WRONG_RETURN_TYPE: { return "Test function with wrong return type"; }
271 2 case SemanticErrorType::LAMBDA_CAPTURE_ESCAPE: { return "Lambda may outlive its captures"; }
272 1 case SemanticErrorType::ERR_PROPAGATION_INVALID_OPERAND: { return "Invalid operand for error propagation operator"; }
273 2 case SemanticErrorType::ERR_PROPAGATION_INVALID_CONTEXT: { return "Error propagation operator used in invalid context"; }
274 2 case SemanticErrorType::DISCARDED_RESULT_VALUE: { return "Discarded Result value"; }
275 ✗ case SemanticErrorType::UNION_AMBIGUITY: { return "Union ambiguity"; }
276 2 case SemanticErrorType::UNION_INFINITE_SIZE: { return "Union with infinite size detected"; }
277 1 case SemanticErrorType::UNION_FIELD_TYPE_NOT_TRIVIAL: { return "Union field type not trivial"; }
278 1 case SemanticErrorType::UNION_FIELD_MUST_NOT_BE_REFERENCE: { return "Union field must not be a reference"; }
279 1 case SemanticErrorType::DUPLICATE_UNION_DEFAULT_VALUE: { return "Duplicate default value in union"; }
280 5 case SemanticErrorType::AMBIGUOUS_SYMBOL: { return "Ambiguous symbol"; }
281 4 case SemanticErrorType::INTERFACE_RETURNED_BY_VALUE: { return "Interface returned by value"; }
282 − default: { panic(Error("Unknown error")); } // LCOV_EXCL_LINE
283 }
284 ✗ }
285