Project

General

Profile

Bug #15449

Range#=== is not using cover in Ruby 2.6

Added by ana06 (Ana Maria Martinez Gomez) 4 months ago. Updated 4 months ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
2.6.0dev (2018-12-20 trunk 66466)
[ruby-core:90660]

Description

irb(main):105:0> ('A'..'Z').cover? 'ANA'
=> true
irb(main):106:0> ('A'..'Z') === 'ANA'
=> false

Is this expected? Should === use cover according to NEWS in Ruby 2.6?

> ruby -v
ruby 2.6.0dev (2018-12-20 trunk 66466) [x86_64-linux]

History

Updated by zverok (Victor Shepelev) 4 months ago

According to code, it first tries to use range_include_internal, which has special handling for strings.

Justification is not obvious, but probably it is an attempt to preserve backwards compatibility?

Updated by ana06 (Ana Maria Martinez Gomez) 4 months ago

If that the case, this should be clarified in NEWS, because it sounds as it was changed for all cases...

Updated by Hanmac (Hans Mackowiak) 4 months ago

That isn't new, that is since 1.9 as #cover? was added

Updated by osyo (manga osyo) 4 months ago

Sorry, Range#=== is called Range#cover? in Ruby 2.6.
see: https://bugs.ruby-lang.org/issues/14575

Also available in: Atom PDF