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>'
Actions
Like0
Like0Like0Like0Like0Like0Like0