PlutoLang / Pluto

A superset of Lua 5.4 with a focus on general-purpose programming.
https://pluto-lang.org/docs/Introduction
MIT License
339 stars 20 forks source link

Read of uninitialized variable #792

Closed XmiliaH closed 2 months ago

XmiliaH commented 2 months ago

The continue statement will update nactvarbeforecontinue. This can happen in a nested scope with more active variables then the ones that will be visible in the until part, resurrecting previous dead variables and allowing to read uninitialized variables.

function read_uninit()
    local val
    repeat
        if val then
            local x, y, z
            continue
        end
    until (function() val=z return 1 end)()
    return val
end

do 
    local x, y
    for k in pairs({}) do end
end

print(read_uninit())