matthewdean/proxy.lua

Errors thrown in metamethods are sometimes incorrect

matthewdean opened this issue · 2 comments

How it is:

Game()
--> attempt to call local 'f' (a userdata value)

How it should be:

Game()
attempt to call global 'Game' (a userdata value)

Partially fixed by not using default metamethods, since they provide no advantage (e.g. if __index is function(t,k) return t[k] end, we might as well leave it out)

@mniip provided a solution:

function echo(...)
  return ...
end

function call(f, ...)
  echo(f)(...) -- if we just did f(...), we would get attempt to call local 'f' (a table value)
end
call({}, 5, 7)
--> attempt to call a table value