The compiler is throwing errors when attempting to switch on Enum values. Of course, this isn't the first problem I've seen with Switch statements today; switching on an Array of string is also broken. The following code is a reproducible test case showing how switch's fail to correctly compile when switching on an enum.
It's important to note that this works if ETestEnum is in the same class that you're switching in. Then it compiles fine. This is wrong considering my test case should work because I'm telling the compiler the class without the enum, depends on the class with the enum.
the compiler error is...
It's important to note that this works if ETestEnum is in the same class that you're switching in. Then it compiles fine. This is wrong considering my test case should work because I'm telling the compiler the class without the enum, depends on the class with the enum.
Code:
class TestClassWithEnum extends Object; enum ETest { Value1, Value2, Value3 }; var ETest TestValue;
Code:
class TestClassNoEnum extends Object DependsOn (TestClassWithEnum); function ShowFailure(TestClassWithEnum classWithEnum) { switch (classWithEnum.TestValue) { case ETest.Value1: // CAUSES COMPILER ERROR break; } }
Code:
Error 3 - Bad or missing expression for token: ETest, in 'Case' - TestClassNoEnum.uc
Comment