lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

dyngeccetor8 <> wrote:

> On 11/15/2017 06:48 AM, Paige DePol wrote:
>> I have produced a very small patch which only makes adjustments in lvm.c to the OP_FORLOOP and OP_FORPREP opcodes to solve the issue of the edge case where math.maxinteger or math.mininteger are used, or where the sign bit overflowed.
> Well, your patch broke version detection test from KHMan.
> Now I can not reproduce cycle going out of limits:
>> for i = math.maxinteger, math.maxinteger do print(i) end
>  9223372036854775807
>> for i = math.maxinteger, math.maxinteger - 2, -1 do print(i) end
>  9223372036854775807
>  9223372036854775806
>  9223372036854775805
>> for i = math.mininteger, math.mininteger + 2, 1 do print(i) end
>  -9223372036854775808
>  -9223372036854775807
>  -9223372036854775806
> (Thank you for patch.)
> -- Martin

Which feature detection test are you referring to? Lua features?
Couldn't one just use the normal _VERSION variable?

The examples you gave are now working as I'd expect they should be. I just
need to look into the corner cases my patch did not address (as mentioned
in reply by Roberto to my patch post).

However, even with the remaining corner cases I think the patch I provided
does seem to allow the previously "broken" loop constructs to now work with
appropriate step values around min/max integers, and loops iterating at
least once at min/max integer values.