Actions
Bug #20936
closedEnumerator's #size returned by Range#reverse_each raises an exception for beginningless Range
Description
(..3).reverse_each.size
is supposed to return Infinity
(at least it does so in Ruby 3.3). But in Ruby 3.4 preview it raises can't iterate from NilClass (TypeError)
what seems a regression.
Ruby 3.3.5:
$ ruby -v -e 'p (..3).reverse_each.size'
ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [x86_64-darwin23]
Infinity
$ ruby -v -e 'p (1..).reverse_each.size'
ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [x86_64-darwin23]
Infinity
3.4.0dev:
$ ruby -v -e 'p (1..).reverse_each.size'
ruby 3.4.0dev (2024-12-09T08:00:19Z master 652b0c13a7) +PRISM [x86_64-darwin23]
Infinity
$ ruby -v -e 'p (..3).reverse_each.size'
ruby 3.4.0dev (2024-12-09T08:00:19Z master 652b0c13a7) +PRISM [x86_64-darwin23]
-e:1:in 'Enumerator#size': can't iterate from NilClass (TypeError)
from -e:1:in '<main>'
Updated by andrykonchin (Andrew Konchin) 11 days ago
- Subject changed from Enumerator#size returned by Range#reverse_each raises an exception to Enumerator's size returned by Range#reverse_each raises an exception
Updated by andrykonchin (Andrew Konchin) 11 days ago
- Subject changed from Enumerator's size returned by Range#reverse_each raises an exception to Enumerator's #size returned by Range#reverse_each raises an exception
Updated by andrykonchin (Andrew Konchin) 11 days ago
- Subject changed from Enumerator's #size returned by Range#reverse_each raises an exception to Enumerator's #size returned by Range#reverse_each raises an exception for beginningless Range
Updated by kyanagi (Kouhei Yanagita) 10 days ago
I made a pull request: https://github.com/ruby/ruby/pull/12301
Does this fix work?
Updated by andrykonchin (Andrew Konchin) 10 days ago
It works. Thank you!
Updated by kyanagi (Kouhei Yanagita) 10 days ago
- Status changed from Open to Closed
Applied in changeset git|3422bfcab6bfdedd10e5c85f5fd6334387712bc6.
[Bug #20936] Fix #size for Range#reverse_each
Actions
Like0
Like0Like0Like0Like0Like0Like0