diff options
author | Ronan Collobert <ronan@collobert.com> | 2015-02-28 06:40:18 +0300 |
---|---|---|
committer | Ronan Collobert <ronan@collobert.com> | 2015-02-28 06:40:18 +0300 |
commit | 8f3b28864473ba58d55beea36bc5d28cdb4c570c (patch) | |
tree | 87e97d8610696680c531ec09c478fb98db65551c /graph.lua | |
parent | b72ffeb038427f00f285b6e722bb560346d318cb (diff) |
fix handling of multiple default values in method mode and added corresponding test case
Diffstat (limited to 'graph.lua')
-rw-r--r-- | graph.lua | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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 |