ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "ko1 (Koichi Sasada)" <redmine@ruby-lang.org>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:52405] [ruby-trunk - Bug #7475] Unexpected behavior of Module#append_features on singleton class
Date: Mon, 18 Feb 2013 08:52:55 +0900	[thread overview]
Message-ID: <redmine.journal-36458.20130218084844@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-7475.20121130105621@ruby-lang.org


Issue #7475 has been updated by ko1 (Koichi Sasada).

Assignee set to matz (Yukihiro Matsumoto)
Target version changed from 1.9.3 to next minor

Matz, could you check it?

----------------------------------------
Bug #7475: Unexpected behavior of Module#append_features on singleton class
https://bugs.ruby-lang.org/issues/7475#change-36458

Author: ernie (Ernie Miller)
Status: Open
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: 
Target version: next minor
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/

  parent reply	other threads:[~2013-02-18  0:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-30  1:56 [ruby-core:50356] [ruby-trunk - Bug #7475][Open] Unexpected behavior of Module#append_features on singleton class ernie (Ernie Miller)
2012-11-30 13:51 ` [ruby-core:50394] [ruby-trunk - Bug #7475] " ernie (Ernie Miller)
2013-02-17 23:52 ` ko1 (Koichi Sasada) [this message]
2013-02-18  1:47 ` [ruby-core:52425] " nobu (Nobuyoshi Nakada)
2019-08-15 15:28 ` [ruby-core:94367] [Ruby master Bug#7475] " merch-redmine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-36458.20130218084844@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).