mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
- Deprecate cast-style conversion from integer to enum. - Make deprecation an error in test mode.
24 lines
299 B
Plaintext
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
|
|
} |