Severity: Medium
Area: Standard library — lib/lua/vm/stdlib/string.ex
Description
string.format raises "bad argument to 'string.format' (invalid option '%.')" when given format specifiers with precision (e.g., %.2f) or width-and-precision combinations. Standard Lua 5.3/5.4 supports the full C printf-style format string syntax.
Reproduction
return string.format("%.2f", 3.14159)
-- Expected: "3.14"
-- Actual: ** (Lua.RuntimeException) bad argument to 'string.format' (invalid option '%.')
Workaround
Use %f (full float) or convert manually with math.floor / string concatenation.
Summary Table
| # |
Bug |
Severity |
Status |
| 1 |
local function declarations silently dropped |
High |
Open |
| 2 |
function Table.method() dot-syntax fails at runtime |
High |
Open |
| 3 |
Multiple for loops with the same variable name corrupt register allocation |
High |
Open |
| 4 |
Register overlap in nested functions causes infinite for loops |
Critical |
Fixed |
| 5 |
string.format does not support precision specifiers |
Medium |
Open |
Severity: Medium
Area: Standard library —
lib/lua/vm/stdlib/string.exDescription
string.formatraises"bad argument to 'string.format' (invalid option '%.')"when given format specifiers with precision (e.g.,%.2f) or width-and-precision combinations. Standard Lua 5.3/5.4 supports the full Cprintf-style format string syntax.Reproduction
Workaround
Use
%f(full float) or convert manually withmath.floor/ string concatenation.Summary Table
local functiondeclarations silently droppedfunction Table.method()dot-syntax fails at runtimeforloops with the same variable name corrupt register allocationforloopsstring.formatdoes not support precision specifiers