Removed 'int' size limit for string.rep

This commit is contained in:
Roberto Ierusalimschy
2024-06-21 16:26:49 -03:00
parent ec65ab878e
commit ef28e5f789
2 changed files with 5 additions and 16 deletions

View File

@@ -109,10 +109,9 @@ assert(string.rep('teste', 0) == '')
assert(string.rep('t<EFBFBD>s\00t<EFBFBD>', 2) == 't<EFBFBD>s\0t<EFBFBD>t<EFBFBD>s\000t<EFBFBD>')
assert(string.rep('', 10) == '')
if string.packsize("i") == 4 then
-- result length would be 2^31 (int overflow)
checkerror("too large", string.rep, 'aa', (1 << 30))
checkerror("too large", string.rep, 'a', (1 << 30), ',')
do
checkerror("too large", string.rep, 'aa', math.maxinteger);
checkerror("too large", string.rep, 'a', math.maxinteger/2, ',')
end
-- repetitions with separator