Skip to content

Object#clone does not copy the singleton class's instance variables #135

Closed

Description

@Largo

Object#clone copies the singleton class, but not the singleton class's own instance variables:

x = Object.new
class << x; instance_variable_set(:@s, 2); end
p x.clone.singleton_class.instance_variables
# CRuby: [:@s]   IronRuby: []

Found by running the scripts PR #119 deleted (Tests/Experiments, Tests/Legacy) on CRuby 4.0.9 and on IronRuby built from master c7f70cf (net10.0, Linux). (Experiments/Clone/AllObjects.rb, initcpy_instance_singleton.rb)

Activity

  1. added a commit that references this issue on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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