fengari-lua / fengari

🌙 φεγγάρι - The Lua VM written in JS ES6 for Node and the browser

Home Page:https://fengari.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

String Lib repeat implementation is slightly incorrect

KevBruner opened this issue · comments

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 )

Seems to work for me:

a=string.rep("hello", -1);
print(type(a), #a) -- output: string	0

Sorry, I wasn't on the latest code. This does seem to have been addressed in the head revision.

Which code were you on? I think the code has been the same for all releases so far.