diff options
author | Jérôme Parent-Lévesque <[email protected]> | 2025-03-15 15:05:50 -0400 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2025-03-17 16:26:23 +0900 |
commit | b5cdbadeeddd2b8e834b9d5565c13fcc43f3e684 (patch) | |
tree | 6075326c8bfd5d2c5026f3ffd1022ee636742418 /range.c | |
parent | 3e04f7b69fb56eac88b56f491b6a298fcc28b7f9 (diff) |
[Bug #21185] Fix Range#overlap? with infinite range
Infinite ranges, i.e. unbounded ranges, should overlap with any other range
which wasn't the case in the following example: (0..3).overlap?(nil..nil)
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12937
Diffstat (limited to 'range.c')
-rw-r--r-- | range.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -2561,7 +2561,7 @@ range_overlap(VALUE range, VALUE other) /* if both begin values are equal, no more comparisons needed */ if (rb_cmpint(cmp, self_beg, other_beg) == 0) return Qtrue; } - else if (NIL_P(self_beg) && !NIL_P(self_end) && NIL_P(other_beg)) { + else if (NIL_P(self_beg) && !NIL_P(self_end) && NIL_P(other_beg) && !NIL_P(other_end)) { VALUE cmp = rb_funcall(self_end, id_cmp, 1, other_end); return RBOOL(!NIL_P(cmp)); } |