Closed luarockr closed 6 years ago
Thanks for finding this bug! I fixed it in fdc907cbd67c15ab0843ebe809d154daf3bb455a.
The previous code allowed only an identifier (like a variable i
) as condition in CASE statements, this was an intentional limitation, but the code was not handling properly unsupported cases like the ones in your examples.
With my latest commit, now the compiler supports any integer expression for CASE conditions, your examples work now.
when using expressions or calls returning INTEGER in CASE ... OF, compiler gives errors or raises exceptions. e.g.
gives CaseTest.Mod:12:10: inadmissible type CaseTest.Mod:13:10: undef CaseTest.Mod:13:11: not a record CaseTest.Mod:13:22: too many params CaseTest.Mod:15:13: compilation FAILED
raises CaseTest2.Mod:9:15: undef CaseTest2.Mod:10:15: undef CaseTest2.Mod:11:15: undef CaseTest2.Mod:12:3: undef CaseTest2.Mod:13:10: OF expected Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1 at OJG.CaseOut(OJG.Mod:1930) at OJP.CasePart(OJP.Mod:759) at OJP.StatSequence(OJP.Mod:910) at OJP.Module(OJP.Mod:1356) at OJP.Compile(OJP.Mod:1384) at oberonc.Main(oberonc.Mod:41) at oberonc.main(oberonc.Mod)