Issue #6374 has been reported by Sega100500 (妊快把忍快抄 圻忪抉志).

----------------------------------------
Bug #6374: Acces to initialized class variable from included module
https://bugs.ruby-lang.org/issues/6374

Author: Sega100500 (妊快把忍快抄 圻忪抉志)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 1.9.3
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]


# Description of bug (?) below in comments of code
# May by it is not a bug, but feature ?

module Variables

	def print_var
		print "In module #{self.class.name}: #{@variable}\n"
	end

	def print_class_var
		print "In module class-variable #{self.class.name}: #{@@class_variable}\n"
	end

	def set_variables(var, cvar)
		@variable = var
		@@class_variable = cvar
	end

end


class A

	include Variables

	def initialize(var, cvar)
		@variable = var
		@@class_variable = cvar
	end

	def print_variables
		print "variables: #{@variable}, #{@@class_variable}\n"
	end

	def self.print_class_a_variables
		print "Class '#{self.class.name}' variable: #{@@class_variable}\n"
	end

end

class B < A
end

a = A.new(123, 456)

A.print_class_a_variables
B.print_class_a_variables

a.print_variables

a.print_var

a.print_class_var # fail: :8:in `print_class_var': uninitialized class variable @@class_variable in Variables (NameError)
									# Why? I set '@@class_variable` in 'initialize'

a.set_variables(12, 33) # Once again set '@@class_variavle'

a.print_class_var # But this method is tested


-- 
http://bugs.ruby-lang.org/