diff options
author | Ronan Collobert <ronan@collobert.com> | 2014-02-28 19:28:35 +0400 |
---|---|---|
committer | Ronan Collobert <ronan@collobert.com> | 2014-02-28 19:28:35 +0400 |
commit | ab439b5e7c89588230635226837550ac07abc2ee (patch) | |
tree | 54e287a60d1483c6532aba721d85ebe3b8fcb0e3 | |
parent | fce08c8ba32afdb62f10ab24edc8812700d578cc (diff) |
opt argument can be also nil...
-rw-r--r-- | init.lua | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -69,7 +69,11 @@ local function generateargcheck__(txt, argdefs, funcname, vars, named) end argdef.luaname = named and string.format('arg.%s', argdef.name) or string.format('select(%d, ...)', argidx) if argdef.check and argdef:check() then - table.insert(checks, argdef:check()) + if argdef.opt then + table.insert(checks, string.format("(type(%s) == 'nil' or %s)", argdef.luaname, argdef:check())) + else + table.insert(checks, argdef:check()) + end end if argdef.read then if argdef:read() then |