Skip to content

loop with try catch body emitted invalid lua code #1598

@admiralnelson

Description

@admiralnelson
const factionKeys = [
    "bretonnia1",
    "bretonnia1",
    "bretonnia1",
    "bretonnia1",
    "bretonnia12"
]

declare interface OpaqueObject {}
declare function GetFaction(factionKey: string) : OpaqueObject

for (const f of factionKeys) {
    try {
        const nativeInterface = GetFaction(f)
    } catch {
        break
    }
}

for (let i = 0; i < factionKeys.length; i++) {
    try {
        const nativeInterface = GetFaction(f)
    } catch {
        break
    }
}

while(true) {
    try {
        const nativeInterface = GetFaction(factionKeys[0])
    } catch {
        break
    }
}

do {
    try {
        const nativeInterface = GetFaction(factionKeys[0])
    } catch {
        break
    }
} while (!false)

output

--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
factionKeys = {
    "bretonnia1",
    "bretonnia1",
    "bretonnia1",
    "bretonnia1",
    "bretonnia12"
}
for ____, f in ipairs(factionKeys) do
    do
        local function ____catch()
            break  -- <-- this caused syntax error
        end
        local ____try = pcall(function()
            local nativeInterface = GetFaction(nil, f)
        end)
        if not ____try then
            ____catch()
        end
    end
end
do
    i = 0
    while i < #factionKeys do
        do
            local function ____catch()
                break -- <-- this caused syntax error
            end
            local ____try = pcall(function()
                local nativeInterface = GetFaction(nil, f)
            end)
            if not ____try then
                ____catch()
            end
        end
        i = i + 1
    end
end
while true do
    do
        local function ____catch()
            break -- <-- this caused syntax error
        end
        local ____try = pcall(function()
            local nativeInterface = GetFaction(nil, factionKeys[1])
        end)
        if not ____try then
            ____catch()
        end
    end
end
repeat
    do
        do
            local function ____catch()
                break -- <-- this caused syntax error
            end
            local ____try = pcall(function()
                local nativeInterface = GetFaction(nil, factionKeys[1])
            end)
            if not ____try then
                ____catch()
            end
        end
    end
until false

playground link
https://typescripttolua.github.io/play/#code/MYewdgzgLgBAZgQ2FAluA0gUwJ4RgXhgG0AoGcmAIgCMAnTKcMFBARkoBoyKb7GxmbTt3K8GTFuy4UqdcQMnCZY-oNYAmSiQC6JEgBNMwADYJ6MFGCiZaiYJhgB5AA4IAjgFdMj6gCsjsADeAL4GRqbmcB5gyGhgMADiDABiSKjgABR26WBY2ABcMNC0lgDmAJQwhS7uXj7+yHpwILQwGaCQsHAwIN3ZcXkQlYEiMFC02DAjMjId0DBgCKgAbpgAklY2dg6ESVCpsZlw5aPBMMBLwAAWU6MycggA1qckoSTNrRnGDBYEMAAMAG5fgAeeBpAY4CAAOm+YFKUCuwJQAGoUcNRuNJtMZuQ5rBFit1ptbEgdokUhCjicZGcLlBrrdceQHs9aa89AB3K4ob4ZcZeDEyLFM5n4hZLFCrDbWUn2P57A45LJU3JQoj-bQ0ih0y43HG41kvN76ECi8gig0zcWEqXE2XbBWUw5gFUuwYarWnc5680zI3ss7c3kODIAQkQxggmHKQA

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy