Skip to content

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

@AdamMil

Description

@AdamMil

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
while(true)
{
  if(x) continue;
  i++;
}

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

local i;
for( local x; true; i++ )
{
	if (x)
	{
		continue;
	}
}

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions