kyren / piccolo

An experimental stackless Lua VM implemented in pure Rust
Creative Commons Zero v1.0 Universal
1.62k stars 59 forks source link

Erase unneeded data when tailcalling #54

Closed Jengamon closed 4 months ago

Jengamon commented 4 months ago

This should fix #53 by fill part of the stack with nil that cannot be actually used by the tailcalled function (because it does not have varargs and it was not passed in as an argument).

Jengamon commented 4 months ago

Nope, current "fix" breaks:

local b = {}
function b.inner(a, bk)
  print(a, bk, b == bk)
end
setmetatable(b, {
  __call = function(_, ...)
    b.inner(...)
    return b.inner(...)
  end
})

local a = b("a")

function a(b, c)
  print(b, c, b==a)
end
function d(_, ...)
  a(...)
  return a(...)
end
d("s")

let me do more digging (or it's more like it never fixed the above now that I've dug more)

Jengamon commented 4 months ago

this doesn't work properly so closing