[#102393] [Ruby master Feature#17608] Compact and sum in one step — sawadatsuyoshi@...

Issue #17608 has been reported by sawa (Tsuyoshi Sawada).

13 messages 2021/02/04

[#102438] [Ruby master Bug#17619] if false foo=42; end creates a foo local variable set to nil — pkmuldoon@...

Issue #17619 has been reported by pkmuldoon (Phil Muldoon).

10 messages 2021/02/10

[#102631] [Ruby master Feature#17660] Expose information about which basic methods have been redefined — tenderlove@...

Issue #17660 has been reported by tenderlovemaking (Aaron Patterson).

9 messages 2021/02/27

[#102639] [Ruby master Misc#17662] The herdoc pattern used in tests does not syntax highlight correctly in many editors — eregontp@...

Issue #17662 has been reported by Eregon (Benoit Daloze).

13 messages 2021/02/27

[#102652] [Ruby master Bug#17664] Behavior of sockets changed in Ruby 3.0 to non-blocking — ciconia@...

Issue #17664 has been reported by ciconia (Sharon Rosner).

23 messages 2021/02/28

[ruby-core:102561] [Ruby master Misc#17637] Endless ranges with `nil` boundary weird behavior

From: marcandre-ruby-core@...
Date: 2021-02-17 14:29:36 UTC
List: ruby-core #102561
Issue #17637 has been updated by marcandre (Marc-Andre Lafortune).


It's not clear what you are proposing. If it is to restore previous behavior, this won't be acceptable because of compatibility.

Note: you should be using `size` (lazy), not `count` (typically exhaustive):

```ruby
(0..nil).size # => Infinity
(0..Float::INFINITY).size # => Infinity
```


----------------------------------------
Misc #17637: Endless ranges with `nil` boundary weird behavior
https://bugs.ruby-lang.org/issues/17637#change-90463

* Author: gud (gud gud)
* Status: Open
* Priority: Normal
----------------------------------------

Basically it's about this https://andycroll.com/ruby/watch-out-for-nils-in-ranges/

Since Ruby 2.6 we have this weird syntax (0..nil) which is really really bug prone

e.g. we have dynamic upper boundary like

```
lower = 0
upper = some_method(arg1, arg2)

(lower..upper).each do { |s| some_method2(s) }
```

We rarely do `nil` checks in Ruby so it's really easy to have Infinity loop in the end.
Previous Argument error was more intuitive since it throws exception instead of silently looping forever.

+ some additional strange behavior:

```
(0..nil).count
=> Infinity

(0..Float::INFINITY).count
=> hangs, I guess same infinity loop
```

Having explicit parameter `Float::INFINITY` (as in previous versions) looks more like a proper design instead of allowing `nil` as a valid parameter.

You may think of it as **I would like to have a range from 0 to nothing, what is it actually ?**
And I guess the answer is **Nothing**.
Fixing `(0..Float::INFINITY).count` this case it also important I believe.

Tested on `ruby 2.7.1p83`



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread