Skip to content

Calling :include? on an String Range always returns true in 9.3.0.0 #6864

@Dave1995

Description

@Dave1995

Environment Information

JRuby version:
jruby 9.3.0.0 (2.6.8) 2021-09-17 85c20e780f OpenJDK 64-Bit Server VM 11.0.11+9-Ubuntu-0ubuntu2.20.04 on 11.0.11+9-Ubuntu-0ubuntu2.20.04 +jit [linux-x86_64]
OS:
Ubuntu 20.04
Linux T480 5.4.0-86-generic #97-Ubuntu SMP Fri Sep 17 19:19:40 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Expected Behavior
I expect the :include? method to have the same behavior as with JRuby 9.2.19 or MRI and return false.

("01".."10").include?("test")
=> false
("01".."10").include?("01")
=> true

Actual Behavior
It looks like :include? always returns true when called on an String Range. :include? still works when it is called on an array, so converting the String Range into an Array and then calling :include? is working fine.

# JRuby 9.3.0.0
("01".."10").include?("test")
=> true
("01".."10").to_a.include?("test")
=> false
# JRuby 9.2.19.0
("01".."10").include?("test")
=> false
# MRI 2.6.8
("01".."10").include?("test")
=> false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions