jmc icon indicating copy to clipboard operation
jmc copied to clipboard

Switch statements don't fully compile with curly braced anon function cases

Open w00tyd00d opened this issue 1 year ago • 1 comments

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

  1. Create a switch statement in any .jmc file.
  2. Use an anonymous execute function within a case that uses curly brackets. Any following cases will be ignored by the compiler.

Screenshots

JMC code: image

Transpiled result: image

Desktop

  • Windows 10

w00tyd00d avatar Nov 01 '23 19:11 w00tyd00d

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.

Nico314159 avatar Nov 02 '23 15:11 Nico314159