Actions
Bug #3080
closedclass_variable_set issue with duped Module
Description
=begin
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
@@cvar
end
def function_get_cvar
@@cvar
end
end
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
end
class IncludesDuped
include Duped
end
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
'
=end
Actions
Like0
Like0Like0Like0Like0Like0