Error when given a form

This commit is contained in:
Kampfkarren 2022-07-27 17:53:15 -07:00
parent c224548781
commit 41fa546a17
2 changed files with 9 additions and 0 deletions

View file

@ -1034,6 +1034,11 @@ static int str_format(lua_State* L)
}
case '*':
{
if (formatItemSize != 1)
{
luaL_error(L, "'%%*' does not take a form");
}
size_t length;
const char* string = luaL_tolstring(L, arg, &length);

View file

@ -146,6 +146,10 @@ end) == false)
assert(string.format("%*", "a\0b\0c") == "a\0b\0c")
assert(string.format("%*", string.rep("doge", 3000)) == string.rep("doge", 3000))
assert(pcall(function()
string.format("%#*", "bad form")
end) == false)
assert(loadstring("return 1\n--comentário sem EOL no final")() == 1)