Skip to content

Weird init_by_lua* behaviour around empty tables, nils, arguments in general. #614

Closed
@datafatmunger

Description

@datafatmunger

The easiest way to reproduce "weirdness":

init_by_lua 'print({})';

Will produce:

nginx: [error] init_by_lua error: init_by_lua:1: bad argument #1 to 'print' (string, number, boolean, or nil expected, got table)
stack traceback:
[C]: in function 'print'
init_by_lua:1: in main chunk

Strange because this works outside of Nginx fine, and even seems to work in content_by_lua.

Specifically in my case, I have similar weirdness:

local upvalues = self:readObject()
for index,upvalue in ipairs(upvalues) do
   if typeidx == LEGACY_TYPE_RECUR_FUNCTION then
      debug.setupvalue(func, index, upvalue)
   elseif upvalue.name == '_ENV' then
      debug.setupvalue(func, index, _ENV)
   else
      debug.setupvalue(func, index, upvalue.value)
   end
end

Results in:

nginx: [error] init_by_lua_file error: ...g/Development/torch/install/share/lua/5.1/torch/File.lua:241: bad argument #1 to 'ipairs' (table expected, got nil)
stack traceback:
    [C]: in function 'ipairs'

Again, code works fine outside of init_by_lua*

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions