feat: implement single-argument reduce with manual iteration and empty-sequence abort
Replace the previous slice-based single-argument reduce implementation with an explicit iterator loop that seeds from the first element. This avoids the out-of-bounds range error on single-element lists and adds a Fiber.abort for empty sequences. Update the test to verify correct behavior for single-element and empty sequences.
This commit is contained in:
@@ -1 +1,2 @@
|
||||
[1].reduce {|a, b| a } // expect runtime error: Range start out of bounds.
|
||||
IO.print([1].reduce {|a, b| 42 }) // expect: 1
|
||||
IO.print([].reduce(1) {|a, b| 42 }) // expect: 1
|
||||
|
||||
Reference in New Issue
Block a user