[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Comparing integer value with number on Lua v5.4.3 with LUA_FLOORN2I=1
- From: David Capello <davidcapello@...>
- Date: Wed, 13 Oct 2021 09:12:13 -0300
Hi Andrew,
> On 12 Oct 2021, at 21:16, Andrew Gierth <andrew@tao11.riddles.org.uk> wrote:
>
>>>>>> "David" == David Capello <davidcapello@gmail.com> writes:
>
> David> I’m not sure if this is a proper fix, but it looks like v5.4.3
> David> (and master branch) contains a bug if we define LUA_FLOORN2I=1
> David> when we try to compare an integer value == a number. This is a
> David> possible fix:
>
> Surely you don't want 1 == 1.4 to compare true, whatever the float to
> integer conversion mode you want to use.
Actually with my patch that comparison fails. The patch works only
when an object is compared with a constant:
local a = 1
assert(a == 1.4) -- doesn’t fail
assert(1.4 == a) -- doesn’t fail
assert(1 == 1.4) -- fails
This is how it was working on Lua 5.3. Without the patch, 5.4 fails here:
local a = 1
assert(a == 1.4)
Anyway I’m not sure if this breaking change on purpose between 5.3 vs 5.4 when LUA_FLOORN2I=1
Kind regards,
- David