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

NutCracker is too eager to replace while loops with for loops #28

AdamMil opened this Issue Feb 4, 2019 · 0 comments


None yet
1 participant
Copy link

AdamMil commented Feb 4, 2019

In DecompileLoopJumpInstruction, if the jump is backwards to the start of the loop it may decompile it as a continue statement, but it doesn't set the UsedBackwardJumpContinue flag, so the postprocessing step may convert it to a for loop improperly. See this code:

local i,x
  if(x) continue;

When compiled and decompiled (assuming some other bugs are fixed), the result is:

local i;
for( local x; true; i++ )
	if (x)

This is not equivalent. In the first example, the increment is skipped if x is true but in the second example it is not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment