Hyphens in module names & -l option

111 views
Skip to first unread message

Michal Domonkos

unread,
Apr 15, 2026, 7:09:11 AMApr 15
to lua-l
Hi there,

Commit 09f3c2372f5dbeaec9f50614a26c1b5761726a88 made the -l CLI option discard
a version suffix, if any, delimited by the LUA_IGMARK (hyphen). Howevever, that
means, module names that contain a hyphen in the name (which doesn't delimit a
version suffix), such as "lua-utf8", will now have the suffix part stripped on
import, too. For example, before the patch:

$ lua -v
Lua 5.4.6 Copyright (C) 1994-2023 Lua.org, PUC-Rio

$ lua -l lua-utf8 -e 'print(_G["lua-utf8"].len("test"))'
4

Whereas on with the patch, the module is added as "lua" to the global table,
and thus the same command now fails:

$ lua -v
Lua 5.4.8 Copyright (C) 1994-2025 Lua.org, PUC-Rio

$ lua -l lua-utf8 -e 'print(_G["lua-utf8"].len("test"))'
lua: (command line):1: attempt to index a nil value (field 'lua-utf8')
stack traceback:
(command line):1: in main chunk
[C]: in ?

$ lua -l lua-utf8 -e 'print(_G["lua"].len("test"))' # "lua" works
4

Now, the following alternative (and perhaps more common?) methods of importing
a module work fine with both versions:

$ lua -l u=lua-utf8 -e 'print(u.len("test"))'
4
$ lua -e 'local u = require("lua-utf8"); print(u.len("test"))'
4

So I'm wondering: were such hyphen-ated names considered with that -l behavior
change, and if not, is it a common enough use case that the patch potentially
breaks the stability promise of the 5.4 version?

Thanks,

--
Michal Domonkos / RPM.org / Red Hat

Roberto Ierusalimschy

unread,
Apr 16, 2026, 4:22:44 PMApr 16
to 'Michal Domonkos' via lua-l
> $ lua -l lua-utf8 -e 'print(_G["lua-utf8"].len("test"))'
> [...]
> So I'm wondering: were such hyphen-ated names considered with that -l behavior
> change, and if not, is it a common enough use case that the patch potentially
> breaks the stability promise of the 5.4 version?

If we go along this line, then commit 65434b4d also broke compatibility,
at it disallowed module names that contain '='.

When the documentation says "global 'mod'", it is implicit that 'mod' is
a valid global name. The fact that _G["lua-utf8"] worked before is a bug,
not a feature.

-- Roberto

Michal Domonkos

unread,
Apr 27, 2026, 7:32:58 AM (6 days ago) Apr 27
to lua-l
On Thursday, April 16, 2026 at 10:22:44 PM UTC+2 Roberto Ierusalimschy wrote:
If we go along this line, then commit 65434b4d also broke compatibility,
at it disallowed module names that contain '='.

When the documentation says "global 'mod'", it is implicit that 'mod' is
a valid global name. The fact that _G["lua-utf8"] worked before is a bug,
not a feature.

Ack, thanks for clarifying.

Michal 
 
Reply all
Reply to author
Forward
0 new messages