Jump to content

Topic on Module talk:TNT/Flow

getting error in Module:TNT

4
AstiGallien (talkcontribs)

i freshly copied Module:TNT from MediaWiki to my wiki and got following error in the testcases:

Module:TNT[edit source]

2 tests failed.

Name Expected Actual
test_doc Lua error -- Module:TNT:124: mw.text.jsonEncode: Cannot use type 'boolean' as a table key
test_link
test_msg / msg31 text message a and b text message b and a
test_msg_errors
test_msg_format
test_msg_format_in_language

is there anything, i missed ?

Erutuon (talkcontribs)

I fixed the boolean table key error with this edit. This module is using pairs to iterate over integer keys starting at 1, but only ipairs is guaranteed to do that. I had never encountered pairs misbehaving, but it did here (tested using this edit). The loop iterated over data.schema.fields[i].name in random order and caused the later loop over data.data to think that the booleans in data.data[i] were names and insert them as keys into params in the table that is given to mw.text.jsonEncode. Replacing pairs with ipairs was the trick: it guarantees that the integer keys are iterated over sequentially.

Erutuon (talkcontribs)

The text message b and a thing was also caused by pairs. this edit fixed it at least in the testcases, though something bad may happen when there are gaps in parameters msg|I18n/Module:TNT/testcases.tab|text_link|3=a|5=b (it probably wouldn't use b) if anybody for some odd reason decides to use that syntax.

Erutuon (talkcontribs)

I'm guessing that the Scribunto installation on this wiki is a different version than on Wikimedia sites, because I've never encountered pairs randomly iterating over integer keys. The parser profiling table says "Lua virtual size" and "Lua estimated memory usage", whereas I see "Lua memory usage" on Wikimedia sites. Maybe that's a feature of the version that calls to Lua on the command line. Wildly guessing though.

Reply to "getting error in Module:TNT"