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

snap_usedef and upvalues #737

Closed
XmiliaH opened this issue Jul 23, 2021 · 1 comment
Closed

snap_usedef and upvalues #737

XmiliaH opened this issue Jul 23, 2021 · 1 comment

Comments

@XmiliaH
Copy link

XmiliaH commented Jul 23, 2021

In some circumstances snap_usedef can flag a slot as dead, however, a potential upvalue could require it as can be seen in the following example:

-- require"jit".off()

local function f(make_up, when)
    local uv, uvf
    if make_up then
        uvf = function() return uv end
    end
    for i = 1, 1000 do
        if i == when then
            uv = "This"
            if i == 0 then end
            string.gsub("", "", {}) -- Force stich
            return uvf
        end
    end
    error("Not here")
end

f(false, 57)
local uvf = f(true, 1)
print(uvf())

The output should be This and not nil as the only to exit f is with the return and uv is previously set. However, snap_usedef will determine that uv is dead, since at the time of compilation no open upvalue exists for uv.

@MikePall
Copy link
Member

Fixed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants