[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade)
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 24 Mar 2014 10:47:24 -0300
> Most common breakage seem to be (%d+) captures. [...]
That is my experience too. (Not sure about the "most common", but sure
about a "quite common".)
> @@ -222,7 +226,11 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) {
> else { /* two numbers with different variants */
> lua_Number n1, n2;
> lua_assert(ttisnumber(t1) && ttisnumber(t2));
> +#if defined LUA_COMPAT_NUMBER_COERCION
> cast_void(tonumber(t1, &n1)); cast_void(tonumber(t2, &n2));
> +#else
> + n1 = cast_num(ivalue(t1)); n2 = cast_num(ivalue(t2));
> +#endif
> return luai_numeq(n1, n2);
> }
> }
I guess this is not needed (and not correct). It is not needed
because neither n1 nor n2 can be strings here (see the 'if' controling
this 'else'); it is incorrect because one of 'n1' or 'n2' will not be
an integer here.
-- Roberto