Project

General

Profile

Bug #3080

class_variable_set issue with duped Module

Added by dolzenko (Evgeniy Dolzhenko) over 10 years ago. Updated almost 8 years ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 1.9.2dev (2010-04-02 trunk 27162) [i686-linux]
Backport:
[ruby-core:29228]

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


Related issues

Related to Ruby master - Bug #3136: reuse of singleton method definition causes SEGVClosedko1 (Koichi Sasada)04/12/2010Actions

Also available in: Atom PDF