diff options
author | Ronan Collobert <ronan@collobert.com> | 2014-04-11 17:36:44 +0400 |
---|---|---|
committer | Ronan Collobert <ronan@collobert.com> | 2014-04-11 17:36:44 +0400 |
commit | 30c99ac57227f171c0ad0a2bcfbe2a8ead66bacf (patch) | |
tree | 8764be6ed4a8f5177d3c6a9195dd789af275686c | |
parent | 53b528299bfa334ddee91c434e7fba7639871b12 (diff) |
bug fix: optional arguments were not properly handled in some cases [huge bug]
-rw-r--r-- | init.lua | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -173,7 +173,7 @@ local function generaterules(rules, named, hasordered) if rule.default or rule.defaulta or rule.defaultf or rule.opt then optidx = optidx + 1 - if bit.band(optidx, optmask) == 0 then + if bit.band(2^(optidx-1), optmask) == 0 then if rule.defaulta then table.insert(defatxt, string.format('%s arg%d = arg%d', indent, ridx, argname2idx(rules, rule.defaulta))) end @@ -181,7 +181,7 @@ local function generaterules(rules, named, hasordered) end end - if not skiprule and aidx <= narg then + if not skiprule then local checktxt if rule.opt and rule.type then checktxt = string.format('(istype(%s, "%s") or istype(%s, "nil"))', rule2arg(rule, aidx, named), rule.type, rule2arg(rule, aidx, named)) |