Module talk:Arguments: Difference between revisions
Appearance
←Blanked the page |
→Iterator corruption: new section |
||
| Line 1: | Line 1: | ||
== Iterator corruption == | |||
{{ping|Mr. Stradivarius}} I found a subtle iterator corruption bug in this module.<syntaxhighlight lang="lua"> | |||
local args = require('Module:Arguments').getArgs(frame) | |||
for k, v in args do | |||
mw.log(k .. '=' .. (v or 'nil') .. ' ') | |||
if args[k .. 'somesuffix'] then | |||
mw.log('Found suffix for ' .. k) | |||
end | |||
end | |||
</syntaxhighlight> Attempting to read the somesuffix argument causes it to be memoized, adding it to the internal table, which apparently can corrupt the iterator and causes some arguments to be skipped. I've noticed this is only reproducible some of the time. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 02:58, 13 April 2014 (UTC) | |||
Revision as of 02:58, 13 April 2014
Iterator corruption
Template:Ping I found a subtle iterator corruption bug in this module.<syntaxhighlight lang="lua"> local args = require('Module:Arguments').getArgs(frame) for k, v in args do
mw.log(k .. '=' .. (v or 'nil') .. ' ')
if args[k .. 'somesuffix'] then
mw.log('Found suffix for ' .. k)
end
end </syntaxhighlight> Attempting to read the somesuffix argument causes it to be memoized, adding it to the internal table, which apparently can corrupt the iterator and causes some arguments to be skipped. I've noticed this is only reproducible some of the time. Jackmcbarn (talk) 02:58, 13 April 2014 (UTC)