Page MenuHomePhabricator

Scribunto hex library uses unnecessary global variables - incompatible with strict
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • The Scribunto hex library declares 5 global variables:
    • hex_tbl on line 39
    • hex_str on line 40
    • last on line 43
    • head on line 62
    • v on line 68

What happens?:

Attempting to use either of the library's functions (to_hex and to_dec) after require("strict") has been called results in an "assign to undeclared variable" error being thrown.

What should have happened instead?:

  • The variables should be declared using local. This would also marginally increase performance.
  • Additionally, it is unnecessary to declare v at all, because it is immediately returned after being declared.

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Related Objects

Event Timeline

The hex library? Can you point to the relevant documentation in the reference manual? https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual

I note these are technically 3rd party libraries. Luaforge seems to be gone these days, so I suspect our versions are now forks...

Change 983954 had a related patch set uploaded (by Reedy; author: Reedy):

[mediawiki/extensions/Scribunto@master] LuaBit: Minor cleanup

https://gerrit.wikimedia.org/r/983954

Change 983954 merged by jenkins-bot:

[mediawiki/extensions/Scribunto@master] LuaBit: Minor cleanup

https://gerrit.wikimedia.org/r/983954

Change 984184 had a related patch set uploaded (by Reedy; author: Reedy):

[mediawiki/extensions/Scribunto@REL1_41] LuaBit: Minor cleanup

https://gerrit.wikimedia.org/r/984184

Change 984185 had a related patch set uploaded (by Reedy; author: Reedy):

[mediawiki/extensions/Scribunto@REL1_40] LuaBit: Minor cleanup

https://gerrit.wikimedia.org/r/984185

Change 984306 had a related patch set uploaded (by Reedy; author: Reedy):

[mediawiki/extensions/Scribunto@REL1_39] LuaBit: Minor cleanup

https://gerrit.wikimedia.org/r/984306

Reedy claimed this task.

Change 984185 merged by jenkins-bot:

[mediawiki/extensions/Scribunto@REL1_40] LuaBit: Minor cleanup

https://gerrit.wikimedia.org/r/984185

Change 984306 merged by jenkins-bot:

[mediawiki/extensions/Scribunto@REL1_39] LuaBit: Minor cleanup

https://gerrit.wikimedia.org/r/984306

Change 984184 merged by jenkins-bot:

[mediawiki/extensions/Scribunto@REL1_41] LuaBit: Minor cleanup

https://gerrit.wikimedia.org/r/984184