jmc
jmc copied to clipboard
Switch statements don't fully compile with curly braced anon function cases
Describe the bug
Switch statements that use an anonymous function (specifically with curly brackets) within a case will prevent any subsequent cases from being compiled. Since it needs curly brackets for it to bug, it seems like it's an error in the parser picking up the curly bracket to end the switch
when it shouldn't.
To Reproduce
- Create a
switch
statement in any.jmc
file. - Use an anonymous
execute
function within a case that uses curly brackets. Any following cases will be ignored by the compiler.
Screenshots
JMC code:
Transpiled result:
Desktop
- Windows 10
Temporary workaround: add a break
statement.
switch ($switch_var) {
case 0:
execute run $result = 0;
case 1:
execute run $result = 1;
case 2:
execute run {
$result = 2;
}
break;
case 3:
execute run $result = 3;
}
compiles to what's expected.