String Lib repeat implementation is slightly incorrect
KevBruner opened this issue · comments
Kevin Bruner commented
string.rep should "Returns the empty string if n is not positive." (from the Lua documentation). The Fengari implementation errors with "resulting string too large" if you pass -1 to string.rep.
The following code works under standard Lua but fails in Fengari
local var = "hello"
var = string.rep( "hello", -1 )
daurnimator commented
Seems to work for me:
a=string.rep("hello", -1);
print(type(a), #a) -- output: string 0
Kevin Bruner commented
Sorry, I wasn't on the latest code. This does seem to have been addressed in the head revision.
daurnimator commented
Which code were you on? I think the code has been the same for all releases so far.