Possible bug in "tonumber"

Possible bug in “tonumber”:
If a variable contains already a number, the function “tonumber(variable)” throws an error “Lua error: attempt to perform arithmetic on a non-number”

Turns out, in fact it returns “nil” if the value is a number already.

you can reproduce it this way:
${tonumber(3)+4}

Is this intended?
Until at least in one of the few latest versions right before 2.1.7 this was no problem: tonumber(x) returned the value as number, even if it was a number already.

Summoning @mjf our Lua numerics super hero.

Just checked behavior in “real” Lua, and it accepts numbers that are already numbers so let me fix this real quick.

Fixed on main, will be on :v2 soon.

1 Like

Thanks a lot, works like expected again!! :slight_smile: