From: "ernie (Ernie Miller)" Date: 2012-11-30T10:56:28+09:00 Subject: [ruby-core:50356] [ruby-trunk - Bug #7475][Open] Unexpected behavior of Module#append_features on singleton class Issue #7475 has been reported by ernie (Ernie Miller). ---------------------------------------- Bug #7475: Unexpected behavior of Module#append_features on singleton class https://bugs.ruby-lang.org/issues/7475 Author: ernie (Ernie Miller) Status: Open Priority: Normal Assignee: Category: Target version: 1.9.3 ruby -v: ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.2.0] A more involved explanation is available at http://erniemiller.org/2012/11/29/ruby-tidbit-include-vs-extend-with-module-class-variables/ In short, the handling of class variables (and constants) when a module is extended vs included is not as expected. Example: module Foo @@foo = 'foo' end class Bar include Foo end class Baz extend Foo end Bar.class_variable_get :@@foo # => "foo" Baz.singleton_class.class_variable_get :@@foo # => NameError: uninitialized class variable @@foo in Class We would expect constant and class variable lookup on the singleton class to work, but it doesn't. Both Rubinius and JRuby seem to behave as expected in this case. Thanks! -- http://bugs.ruby-lang.org/