Ticket #346 (new defect)

Opened 5 years ago

Cannot break out of a loop from within a branch

Reported by: nerdzero Owned by:
Priority: major Milestone:
Component: Cobra Compiler Version: 0.9.4
Keywords: branch, break, loop Cc:


The generated C# treats the 'break' statement as being part of the switch structure instead of breaking out of the loop.

Test case that results in infinite loop.

class Program

    def main

        x = 1

        while true
            branch x
                on 1
                    trace x
                    print "Should not get printed"

        print "done"

One solution is to generate a goto statement in the C#. Some more alternatives are here:

Note: See TracTickets for help on using tickets.