Bug #3080

class_variable_set issue with duped Module

Added by Evgeniy Dolzhenko over 5 years ago. Updated almost 3 years ago.

Assignee:Nobuyoshi Nakada
ruby -v:ruby 1.9.2dev (2010-04-02 trunk 27162) [i686-linux] Backport:


Below is the test case which is failing for me on ruby 1.9.2dev (2010-04-02 trunk 27162) [i686-linux] but works on ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-linux]:

module Original
@@cvar = nil

def self.module_get_cvar

def function_get_cvar

Duped = Original.dup

Original.send(:class_variable_set, :@@cvar, "cvar in Original")
Duped.send(:class_variable_set, :@@cvar, "cvar in Duped")

class IncludesOriginal
include Original

class IncludesDuped
include Duped

puts IncludesOriginal.new.function_get_cvar # => cvar in Original
puts IncludesDuped.new.function_get_cvar # => cvar in Duped

puts Original.module_get_cvar # => cvar in Original

puts Duped.module_get_cvar # => 19_duped_module_class_variable_set_bug.rb:3: warning: class variable access from toplevel
# 19_duped_module_class_variable_set_bug.rb:3:in get_cvar': uninitialized class variable @@cvar in Object (NameError)
# from 19_duped_module_class_variable_set_bug.rb:13:in


Related issues

Related to Ruby trunk - Bug #3136: reuse of singleton method definition causes SEGV Closed 04/12/2010


#1 Updated by Yusuke Endoh over 5 years ago

  • Target version set to 2.0.0


This is similar issue to .
This issue is caused by ISeq#cref_stack instead of ISeq#klass.
This won't be fixed in 1.9.2.

Yusuke Endoh mame@tsg.ne.jp

#2 Updated by Yui NARUSE over 4 years ago

  • Status changed from Open to Assigned
  • Assignee set to Koichi Sasada
  • Target version changed from 2.0.0 to 1.9.3

#3 Updated by Koichi Sasada over 4 years ago

  • Target version changed from 1.9.3 to 2.0.0

Let's discuss after 1.9.3. Sorry.

#4 Updated by Koichi Sasada about 3 years ago

  • Assignee changed from Koichi Sasada to Nobuyoshi Nakada

nobu, could you check it?

#5 Updated by Nobuyoshi Nakada almost 3 years ago

  • Status changed from Assigned to Closed

Also available in: Atom PDF