Files
c3c/test/test_suite/errors/illegal_use_of_optional.c3
Christoffer Lerno 25bccf4883 New faults and syntax (#2034)
- Remove `[?]` syntax.
- Change `int!` to `int?` syntax.
- New `fault` declarations.
- Enum associated values can reference the calling enum.
2025-03-10 00:11:35 +01:00

15 lines
486 B
Plaintext

fn void syntaxErrors()
{
int? i = 0;
while (i + 1) {} // #error: optional, but was 'int?'
if (i + 1) {} // #error: optional, but was 'int?'
for (int x = i;;) {} // #error: 'int?' to 'int'
for (int x = 0; x < i + 1;) {} // #error: optional, but was 'bool?'.
for (int x = 0; x < 10; x += i + 1) {} // #error: Cannot assign an optional value to a non-optional
switch (i + 1) // #error: optional, but was 'int?'
{
default:
i + 1;
}
}