Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
w00tyd00d opened this issue Nov 1, 2023 · 1 comment
Assignees
Labels
Priority: High This needs to be looked into now Type: Bug Something isn't working

Comments

@w00tyd00d
Copy link

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 w00tyd00d added the Type: Bug Something isn't working label Nov 1, 2023
@Nico314159
Copy link
Contributor

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.

@WingedSeal WingedSeal added the Priority: High This needs to be looked into now label Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High This needs to be looked into now Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants