Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/argcheck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonan Collobert <ronan@collobert.com>2014-04-11 17:36:44 +0400
committerRonan Collobert <ronan@collobert.com>2014-04-11 17:36:44 +0400
commit30c99ac57227f171c0ad0a2bcfbe2a8ead66bacf (patch)
tree8764be6ed4a8f5177d3c6a9195dd789af275686c
parent53b528299bfa334ddee91c434e7fba7639871b12 (diff)
bug fix: optional arguments were not properly handled in some cases [huge bug]
-rw-r--r--init.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/init.lua b/init.lua
index be9959b..964a57e 100644
--- a/init.lua
+++ b/init.lua
@@ -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))