Branch: Tag:

2015-06-05

2015-06-05 07:06:51 by Arne Goedeke <el@laramies.com>

enumerate(): fixed integer overflow handling

This change fixes two bugs
1) the overflow checks were incorrect, because signed integers do not
overflow
2) when overflow was actually detected, the code fell back to the
slow path (using f_add) with the last array element as the new start
value, which led to wrong results

598:   test_equal(Array.enumerate(5,2), ({ 0,2,4,6,8 }))   test_equal(Array.enumerate(5,2,7), ({ 7,9,11,13,15 }))   test_equal(Array.enumerate(5,2,7,`-), ({ 7,5,3,1,-1 })) + test_equal(Array.enumerate(5,1,Int.NATIVE_MAX-1), ({ Int.NATIVE_MAX-1, Int.NATIVE_MAX, Int.NATIVE_MAX+1, Int.NATIVE_MAX+2, Int.NATIVE_MAX+3 }))      test_eq([[ Array.reduce(`>>, ({})) ]], 0)   test_eq([[ Array.reduce(`==, ({}), 1) ]], 1)