Skip to content

using statement with break inside for loop generates illigeal lua code #228

@zod

Description

@zod

I'm having issues running code which contains a using statement inside a for loop, which contains a break.

public static void WhileUsingContinue() {
    LinkedList<int> list = new LinkedList<int>();
    for (int i = 0; i < 15; i++) {
        using (LinkedList<int>.Enumerator em = list.GetEnumerator()) {
            if (i == 13)
            {
                break;
            }
        }
        Console.WriteLine("Iteration: {0}", i);
    }
}

Converting this code using CSharp.lua gives this lua code

WhileUsingContinue = function ()
  local list = LinkedListInt32()
  for i = 0, 14 do
    System.using(list:GetEnumerator(), function (em)
      if i == 13 then
        break
      end
    end)
    System.Console.WriteLine("Iteration: {0}", i)
  end
end

The lua interpreter is not able to run this code

lua5.3: error loading module 'out.Tests.TestVector' from file './out/Tests/TestVector.lua':
        ./out/Tests/TestVector.lua:73: <break> at line 71 not inside a loop

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