Continue statements decompiled as goto LabelAtEndOfLoop

4 posts, 0 answers
  1. Orvid
    Orvid avatar
    1 posts
    Member since:
    Nov 2012

    Posted 02 Dec 2012 Link to this post

    Currently a continue statement is getting decompiled as a goto statement that jumps to a label at the end of the loop. While yes, this is the correct behavior for a continue statement, the placement of the label is not valid in C#, because there is no statement after it. I think that it should be fairly easy to implement this by searching up the AST and locating the first loop statement, if the end of that loop statement is the same as the target of the branch, it is a continue statement. Also, this would still leave situations where a goto statement was used to continue in a loop that is farther up broken, for these I would suggest putting a continue statement at the end of the loop immediately after the label, because this would achieve the desired effect. (and is likely how the code was written to begin with) 

    A block of code illustrating the issue, as it is currently decompiled:
    for (int i = 0; i < 32; i++)
    {
        if (SomeBoolean)
            goto EndOfLoop;
        // SomeOtherCodeHere
    EndOfLoop:
    }

    That should be getting decompiled as:
    for (int i = 0; i < 32; i++)
    {
        if (SomeBoolean)
            continue;
        // SomeOtherCodeHere
    }

    Now, the second issue is a bit more confusing, so I'll instead start with what the original code would have been.
    for (int i = 0; i < 32; i++)
    {
        for (int i2 = 0; i2 < 43; i2++)
        {
            if (SomeBoolean)
                goto EndOfOuterLoop;
              // SomeOtherCodeHere
        } 
    EndOfOuterLoop:
        continue;
    }

    Currently, this would be missing the continue statement at the end of the outer loop, which is needed for it to be valid C#.

  2. Yordan Dikov
    Admin
    Yordan Dikov avatar
    69 posts

    Posted 04 Dec 2012 Link to this post

    Hi Orvid,

    Thank you for contacting us. We've logged the problems you've observed and we'll try to provide a fix in one of our future releases. Until then, keep updating and don't hesitate to contact us, should you have any other questions or suggestions.

    Greetings,
    Yordan Dikov
    the Telerik team
    Tell us what you think about JustDecompile. Your opinion matters! You can use our forum, or our JustDecompile UserVoice website for feature requests.
  3. DevCraft banner
  4. 林 avatar
    1 posts
    Member since:
    Dec 2011

    Posted 10 Aug Link to this post

    4 years have passed , this problem is still unsolved .
  5. Alexander
    Admin
    Alexander avatar
    80 posts

    Posted 15 Aug Link to this post

    Hello,

    Rather unfortunately, because of our finite resources we didn't get to this problem yet. It will be fixed at some point, but we cannot really commit on a deadline, so please, update regularly.

    Regards,
    Alexander
    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top