Files
c3c/test/test_suite/enumerations/enum_cast_error.c3
Christoffer Lerno e453e6f9ca - Add enum.from_ordinal and fault.from_ordinal
- Deprecate cast-style conversion from integer to enum.
- Make deprecation an error in test mode.
2024-12-23 15:27:59 +01:00

24 lines
299 B
Plaintext

enum Abc : char { ABC }
fn void foo()
{
Abc x = Abc.from_ordinal(10); // #error: exceeds the max
}
fn void bar()
{
int a;
Abc x = Abc.from_ordinal(a);
}
fn void baz()
{
int a;
Abc x = Abc.from_ordinal(0);
}
fn void abc()
{
int a;
Abc x = Abc.from_ordinal(-1); // #error: negative number
}