[ruby-core:115188] [Ruby master Bug#19977] (nil..nil) === x can raise an exception, differing from Range#cover?

Issue #19977 has been reported by kyanagi (Kouhei Yanagita). ---------------------------------------- Bug #19977: (nil..nil) === x can raise an exception, differing from Range#cover? https://bugs.ruby-lang.org/issues/19977 * Author: kyanagi (Kouhei Yanagita) * Status: Open * Priority: Normal * ruby -v: ruby 3.3.0dev (2023-10-27T03:13:17Z master f9f0cfe785) [arm64-darwin22] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- I investigated Range#=== and Range#cover?, and found that the only difference in behavior between them would be that `(nil..nil) === x` could throw an exception. ``` % ~/tmp/ruby-master/bin/ruby -v ruby 3.3.0dev (2023-10-27T03:13:17Z master f9f0cfe785) [arm64-darwin22] ``` ``` % ~/tmp/ruby-master/bin/ruby -e 'p (nil..nil) === "a"' -e:1:in `===': cannot determine inclusion in beginless/endless ranges (TypeError) p (nil..nil) === "a" ^^^ from -e:1:in `<main>' ``` ``` % ~/tmp/ruby-master/bin/ruby -e 'p (nil..nil).cover?("a")' true ``` Is this difference intended? According to NEWS, `Range#===` uses `cover?` since Ruby 2.6 (For `String`, since Ruby 2.7). Following this, `(nil..nil) === x` should not throw an exception in the same way as `(nil..nil).cover?(x)`. history: `(nil..nil) === "a"` throws an exception since https://github.com/ruby/ruby/commit/04a92a6. For "linear objects" (`Integer`, `Float`, `Numeric`, `Time`), it has beed fixed not to throw an exception on https://github.com/ruby/ruby/commit/fb17c83. related issues: * [Bug #15449] Range#=== is not using cover in Ruby 2.6 * [Bug #18580] Range#include? inconsistency for beginless String ranges * [Bug #19533] Behavior of ===/include? on a beginless/endless range (nil..nil) changed in ruby 3.2 -- https://bugs.ruby-lang.org/

Issue #19977 has been updated by kyanagi (Kouhei Yanagita). The fix will likely be https://github.com/kyanagi/ruby/tree/bug_19977. ---------------------------------------- Bug #19977: (nil..nil) === x can raise an exception, differing from Range#cover? https://bugs.ruby-lang.org/issues/19977#change-105108 * Author: kyanagi (Kouhei Yanagita) * Status: Open * Priority: Normal * ruby -v: ruby 3.3.0dev (2023-10-27T03:13:17Z master f9f0cfe785) [arm64-darwin22] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- I investigated Range#=== and Range#cover?, and found that the only difference in behavior between them would be that `(nil..nil) === x` could throw an exception. ``` % ~/tmp/ruby-master/bin/ruby -v ruby 3.3.0dev (2023-10-27T03:13:17Z master f9f0cfe785) [arm64-darwin22] ``` ``` % ~/tmp/ruby-master/bin/ruby -e 'p (nil..nil) === "a"' -e:1:in `===': cannot determine inclusion in beginless/endless ranges (TypeError) p (nil..nil) === "a" ^^^ from -e:1:in `<main>' ``` ``` % ~/tmp/ruby-master/bin/ruby -e 'p (nil..nil).cover?("a")' true ``` Is this difference intended? According to NEWS, `Range#===` uses `cover?` since Ruby 2.6 (For `String`, since Ruby 2.7). Following this, `(nil..nil) === x` should not throw an exception in the same way as `(nil..nil).cover?(x)`. history: `(nil..nil) === "a"` throws an exception since https://github.com/ruby/ruby/commit/04a92a6. For "linear objects" (`Integer`, `Float`, `Numeric`, `Time`), it has beed fixed not to throw an exception on https://github.com/ruby/ruby/commit/fb17c83. related issues: * [Bug #15449] Range#=== is not using cover in Ruby 2.6 * [Bug #18580] Range#include? inconsistency for beginless String ranges * [Bug #19533] Behavior of ===/include? on a beginless/endless range (nil..nil) changed in ruby 3.2 -- https://bugs.ruby-lang.org/

Issue #19977 has been updated by kyanagi (Kouhei Yanagita). Matz had taken the decision to make `(nil..nil) === any_object #=> true` in DevMeeting-2023-04-11. Therefore, we can conclude that this behavior is a bug. https://github.com/ruby/dev-meeting-log/blob/master/2023/DevMeeting-2023-04-... I created a PR: https://github.com/ruby/ruby/pull/8797 ---------------------------------------- Bug #19977: (nil..nil) === x can raise an exception, differing from Range#cover? https://bugs.ruby-lang.org/issues/19977#change-105111 * Author: kyanagi (Kouhei Yanagita) * Status: Open * Priority: Normal * ruby -v: ruby 3.3.0dev (2023-10-27T03:13:17Z master f9f0cfe785) [arm64-darwin22] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- I investigated Range#=== and Range#cover?, and found that the only difference in behavior between them would be that `(nil..nil) === x` could throw an exception. ``` % ~/tmp/ruby-master/bin/ruby -v ruby 3.3.0dev (2023-10-27T03:13:17Z master f9f0cfe785) [arm64-darwin22] ``` ``` % ~/tmp/ruby-master/bin/ruby -e 'p (nil..nil) === "a"' -e:1:in `===': cannot determine inclusion in beginless/endless ranges (TypeError) p (nil..nil) === "a" ^^^ from -e:1:in `<main>' ``` ``` % ~/tmp/ruby-master/bin/ruby -e 'p (nil..nil).cover?("a")' true ``` Is this difference intended? According to NEWS, `Range#===` uses `cover?` since Ruby 2.6 (For `String`, since Ruby 2.7). Following this, `(nil..nil) === x` should not throw an exception in the same way as `(nil..nil).cover?(x)`. history: `(nil..nil) === "a"` throws an exception since https://github.com/ruby/ruby/commit/04a92a6. For "linear objects" (`Integer`, `Float`, `Numeric`, `Time`), it has beed fixed not to throw an exception on https://github.com/ruby/ruby/commit/fb17c83. related issues: * [Bug #15449] Range#=== is not using cover in Ruby 2.6 * [Bug #18580] Range#include? inconsistency for beginless String ranges * [Bug #19533] Behavior of ===/include? on a beginless/endless range (nil..nil) changed in ruby 3.2 -- https://bugs.ruby-lang.org/

Issue #19977 has been updated by knu (Akinori MUSHA). Matz agreed to fix this. ---------------------------------------- Bug #19977: (nil..nil) === x can raise an exception, differing from Range#cover? https://bugs.ruby-lang.org/issues/19977#change-105241 * Author: kyanagi (Kouhei Yanagita) * Status: Open * Priority: Normal * ruby -v: ruby 3.3.0dev (2023-10-27T03:13:17Z master f9f0cfe785) [arm64-darwin22] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- I investigated Range#=== and Range#cover?, and found that the only difference in behavior between them would be that `(nil..nil) === x` could throw an exception. ``` % ~/tmp/ruby-master/bin/ruby -v ruby 3.3.0dev (2023-10-27T03:13:17Z master f9f0cfe785) [arm64-darwin22] ``` ``` % ~/tmp/ruby-master/bin/ruby -e 'p (nil..nil) === "a"' -e:1:in `===': cannot determine inclusion in beginless/endless ranges (TypeError) p (nil..nil) === "a" ^^^ from -e:1:in `<main>' ``` ``` % ~/tmp/ruby-master/bin/ruby -e 'p (nil..nil).cover?("a")' true ``` Is this difference intended? According to NEWS, `Range#===` uses `cover?` since Ruby 2.6 (For `String`, since Ruby 2.7). Following this, `(nil..nil) === x` should not throw an exception in the same way as `(nil..nil).cover?(x)`. history: `(nil..nil) === "a"` throws an exception since https://github.com/ruby/ruby/commit/04a92a6. For "linear objects" (`Integer`, `Float`, `Numeric`, `Time`), it has beed fixed not to throw an exception on https://github.com/ruby/ruby/commit/fb17c83. related issues: * [Bug #15449] Range#=== is not using cover in Ruby 2.6 * [Bug #18580] Range#include? inconsistency for beginless String ranges * [Bug #19533] Behavior of ===/include? on a beginless/endless range (nil..nil) changed in ruby 3.2 -- https://bugs.ruby-lang.org/

Issue #19977 has been updated by kyanagi (Kouhei Yanagita). Can this fix be included in 3.3.0? ---------------------------------------- Bug #19977: (nil..nil) === x can raise an exception, differing from Range#cover? https://bugs.ruby-lang.org/issues/19977#change-105545 * Author: kyanagi (Kouhei Yanagita) * Status: Open * Priority: Normal * ruby -v: ruby 3.3.0dev (2023-10-27T03:13:17Z master f9f0cfe785) [arm64-darwin22] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- I investigated Range#=== and Range#cover?, and found that the only difference in behavior between them would be that `(nil..nil) === x` could throw an exception. ``` % ~/tmp/ruby-master/bin/ruby -v ruby 3.3.0dev (2023-10-27T03:13:17Z master f9f0cfe785) [arm64-darwin22] ``` ``` % ~/tmp/ruby-master/bin/ruby -e 'p (nil..nil) === "a"' -e:1:in `===': cannot determine inclusion in beginless/endless ranges (TypeError) p (nil..nil) === "a" ^^^ from -e:1:in `<main>' ``` ``` % ~/tmp/ruby-master/bin/ruby -e 'p (nil..nil).cover?("a")' true ``` Is this difference intended? According to NEWS, `Range#===` uses `cover?` since Ruby 2.6 (For `String`, since Ruby 2.7). Following this, `(nil..nil) === x` should not throw an exception in the same way as `(nil..nil).cover?(x)`. history: `(nil..nil) === "a"` throws an exception since https://github.com/ruby/ruby/commit/04a92a6. For "linear objects" (`Integer`, `Float`, `Numeric`, `Time`), it has beed fixed not to throw an exception on https://github.com/ruby/ruby/commit/fb17c83. related issues: * [Bug #15449] Range#=== is not using cover in Ruby 2.6 * [Bug #18580] Range#include? inconsistency for beginless String ranges * [Bug #19533] Behavior of ===/include? on a beginless/endless range (nil..nil) changed in ruby 3.2 -- https://bugs.ruby-lang.org/

Issue #19977 has been updated by knu (Akinori MUSHA). I've approved the PR and I'll see if @nobu agrees. I definitely would love to see this merged to 3.3. ---------------------------------------- Bug #19977: (nil..nil) === x can raise an exception, differing from Range#cover? https://bugs.ruby-lang.org/issues/19977#change-105804 * Author: kyanagi (Kouhei Yanagita) * Status: Open * Priority: Normal * ruby -v: ruby 3.3.0dev (2023-10-27T03:13:17Z master f9f0cfe785) [arm64-darwin22] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- I investigated Range#=== and Range#cover?, and found that the only difference in behavior between them would be that `(nil..nil) === x` could throw an exception. ``` % ~/tmp/ruby-master/bin/ruby -v ruby 3.3.0dev (2023-10-27T03:13:17Z master f9f0cfe785) [arm64-darwin22] ``` ``` % ~/tmp/ruby-master/bin/ruby -e 'p (nil..nil) === "a"' -e:1:in `===': cannot determine inclusion in beginless/endless ranges (TypeError) p (nil..nil) === "a" ^^^ from -e:1:in `<main>' ``` ``` % ~/tmp/ruby-master/bin/ruby -e 'p (nil..nil).cover?("a")' true ``` Is this difference intended? According to NEWS, `Range#===` uses `cover?` since Ruby 2.6 (For `String`, since Ruby 2.7). Following this, `(nil..nil) === x` should not throw an exception in the same way as `(nil..nil).cover?(x)`. history: `(nil..nil) === "a"` throws an exception since https://github.com/ruby/ruby/commit/04a92a6. For "linear objects" (`Integer`, `Float`, `Numeric`, `Time`), it has beed fixed not to throw an exception on https://github.com/ruby/ruby/commit/fb17c83. related issues: * [Bug #15449] Range#=== is not using cover in Ruby 2.6 * [Bug #18580] Range#include? inconsistency for beginless String ranges * [Bug #19533] Behavior of ===/include? on a beginless/endless range (nil..nil) changed in ruby 3.2 -- https://bugs.ruby-lang.org/
participants (2)
-
knu (Akinori MUSHA)
-
kyanagi (Kouhei Yanagita)