Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw exception in catch block will prevent the finally block executing #1555

Open
fadabaerobe6 opened this issue Apr 29, 2024 · 0 comments
Open

Comments

@fadabaerobe6
Copy link

try{
    throw new Exception('test')
}catch(e){
    console.log(e)
    throw e
}finally{
    console.log('end');
}

will compile to

--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
-- Lua Library inline imports
local function __TS__New(target, ...)
    local instance = setmetatable({}, target.prototype)
    instance:____constructor(...)
    return instance
end
-- End of Lua Library inline imports
do
    local function ____catch(e)
        print(e)
        error(e, 0)
    end
    local ____try, ____hasReturned = pcall(function()
        error(
            __TS__New(Exception, "test"),
            0
        )
    end)
    if not ____try then
        ____catch(____hasReturned)
    end
    do
        print("end")
    end
end

In standard JavaScript logic, the content within the finally block should be executed.

@fadabaerobe6 fadabaerobe6 changed the title Throw exception in catch block while prevent the finally block executing Throw exception in catch block will prevent the finally block executing Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant