lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2009/8/21 Thomas Harning Jr. <harningt@gmail.com>:
> I suspect this may have been left in from when I made patches before
> since I hadn't quite understood all the vararg handling then.
> If that fix doesn't work... then the pack/unpack will need to capture
> the # of args to make sure nil args are passed in....
> Fix:
>    if not res then
>        local params = {n = select('#', ...), ...}
>        local newf = function() return f(unpack(params, 1, n)) end
>        co = coroutine.create(newf)
>    end

You're not properly accessing n. So use either n in the table:
    if not res then
        local params = {n = select('#', ...), ...}
        local newf = function() return f(unpack(params, 1, params.n)) end
        co = coroutine.create(newf)
    end
or n as an upvalue:
    if not res then
        local n,params, = select('#', ...),{...}
        local newf = function() return f(unpack(params, 1, n)) end
        co = coroutine.create(newf)
    end