Skip to content

Bug: Hash#compare_by_identity does not work with string keys #2615

Open
@takaram

Description

@takaram

Describe the bug
Hash objects don't respect the object id of string keys even when compare_by_identity enabled.

Opal version: 1.8.2

To Reproduce
Sample code:

str1 = "foo"
str2 = str1.dup
hash = {}.compare_by_identity
hash[str1] = 1

p [str1.object_id, str2.object_id]
p [hash[str1], hash[str2]]
$ bin/opal -v test.rb
Opal v2.0.0dev
[58, 60]
[1, 1]
$ ruby -v test.rb
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
[60, 80]
[1, nil]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions