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>2015-02-28 06:40:18 +0300
committerRonan Collobert <ronan@collobert.com>2015-02-28 06:40:18 +0300
commit8f3b28864473ba58d55beea36bc5d28cdb4c570c (patch)
tree87e97d8610696680c531ec09c478fb98db65551c /graph.lua
parentb72ffeb038427f00f285b6e722bb560346d318cb (diff)
fix handling of multiple default values in method mode and added corresponding test case
Diffstat (limited to 'graph.lua')
-rw-r--r--graph.lua9
1 files changed, 5 insertions, 4 deletions
diff --git a/graph.lua b/graph.lua
index 2c38ed7..172c50b 100644
--- a/graph.lua
+++ b/graph.lua
@@ -271,12 +271,13 @@ function ACN:generate_ordered_or_named(code, upvalues, rulestype, depth)
local defaultrules = rules2defaultrules(rules, rulesmask)
local defacode = {}
for _, rule in ipairs(defaultrules) do
+ local defidx = rulestype == 'M' and rule.__ridx+1 or rule.__ridx
if rule.default ~= nil then
- table.insert(code, string.format(' %slocal arg%d = arg%s_%dd', string.rep(' ', depth), rule.__ridx, id, rule.__ridx))
- upvalues[string.format('arg%s_%dd', id, rule.__ridx)] = rule.default
+ table.insert(code, string.format(' %slocal arg%d = arg%s_%dd', string.rep(' ', depth), rule.__ridx, id, defidx))
+ upvalues[string.format('arg%s_%dd', id, defidx)] = rule.default
elseif rule.defaultf then
- table.insert(code, string.format(' %slocal arg%d = arg%s_%df()', string.rep(' ', depth), rule.__ridx, id, rule.__ridx))
- upvalues[string.format('arg%s_%df', id, rule.__ridx)] = rule.defaultf
+ table.insert(code, string.format(' %slocal arg%d = arg%s_%df()', string.rep(' ', depth), rule.__ridx, id, defidx))
+ upvalues[string.format('arg%s_%df', id, defidx)] = rule.defaultf
elseif rule.opt then
table.insert(code, string.format(' %slocal arg%d', string.rep(' ', depth), rule.__ridx))
elseif rule.defaulta then