polserver/testsuite/escript/enum/enum14.src
Kevin Eady 0fcc5060af
Enum class fixes (#805)
* fix enum classes entries without initializer

* docs

* update grammar to support scoped identifiers in case labels

* add support for enum class constants in case statements

* add ScopableName to ConstDeclaration; formatting fixes; tests

* update docs
2025-08-19 09:07:02 +02:00

16 lines
354 B
Text

const BAR := 1234;
enum class MyEnum
FOO := 1,
BAR := MyEnum::FOO * 2, // 1*2 = 2
BAZ := BAR * 2, // 2*2 = 4
BLUB := ::BAR, // global BAR, 1234
BLOB := BAR * ::BAR // global BAR * local bar = 1234 * 2 = 2468
endenum
print( BAR );
print( MyEnum::FOO );
print( MyEnum::BAR );
print( MyEnum::BAZ );
print( MyEnum::BLUB );
print( MyEnum::BLOB );