Open rjharmon opened 10 months ago
This syntax error is due to the parser currently expecting at least one of Int
, []Data
, Map[Data]Data
or ByteArray
as an additional switch case in order to detect data-switch vs regular switch. I guess that doesn't work in case you're not interested in any of those cases and just want to look at enums and enum variants. I'll need some time to come up with a consistent way to handle this edge-case.
For the note: the syntax is sadly not perfectly consistent with the rest of the language, but the following should work:
foo.switch{(index: Int, []Data) => ...}
Soon I'll expose the auto-generated from_data_safe
method though, which might be a better fit for your use-case:
MyEnum::from_data_safe(data) -> Option[MyEnum]
Error:
MyEnum isn't a valid enum member of Data
foo.switch{ (index: Int, fields: Data[]) => ... }
works.Note:
foo.switch{ (index: Int, _) => ... }
gives a syntax error. Not sure if that's as intended.