Skip to content

as.rb attempts to redefine object_id #310

@s2k

Description

@s2k

Behaviour

When, for example, running irb and requiring facets (using Ruby 3.4.2) a warning is displayed:

> irb -r facets
…/.rbenv/versions/3.4.2/lib/ruby/gems/3.4.0/gems/facets-3.1.0/lib/core/facets/kernel/as.rb:103: warning: redefining 'object_id' may cause serious problems
irb(main):001> RUBY_DESCRIPTION
=> "ruby 3.4.2 (2025-02-15 revision d2930f8e7a) +YJIT +PRISM [arm64-darwin24]"

Should object_id be included in the regex to exclude operators and binding?
If so, this should do:

lib/core/facets/kernel/as.rb:103:

  private(*instance_methods.select { |m| m !~ /(^__|^\W|^binding|^object_id$)/ })

Context:

  • Ruby version: 3.3.8, 3.4.1, 3.4.2, 3.5.0-preview1
  • OS: macOS Sequoia 15.4.1 arm64

Note that using Ruby 3.1.6 do not show this behaviour.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions