Bug #3423

Inconsistent behaviour of Module#const_get with included modules

Added by Magnus Holm almost 4 years ago. Updated almost 3 years ago.

[ruby-core:30720]
Status:Closed
Priority:Low
Assignee:Yukihiro Matsumoto
Category:core
Target version:1.9.3
ruby -v:ruby 1.9.2dev (2010-05-31 revision 28117) [x86_64-darwin10.3.0] Backport:

Description

=begin
module Foo
A = 1
end

class Object
include Foo
end

class Bar
include Foo
end

Object.constget(:A, false) # => works fine
Bar.const
get(:A, false) # => raises error

Untested patch attached. This might also fix #3422.
=end

yay.diff Magnifier (389 Bytes) Magnus Holm, 06/11/2010 04:16 AM


Related issues

Related to ruby-trunk - Bug #5264: Commit 33157 Closed 09/02/2011
Duplicated by ruby-trunk - Bug #3422: Object.const_get(:A, false) can access BasicObject::A Closed 06/11/2010

Associated revisions

Revision 32283
Added by Yukihiro Matsumoto almost 3 years ago

  • variable.c (rbconstget0): should not look for superclasses if the second optional argument is given for #constget(). fix [Bug #3422] [Bug #3423]

Revision 32327
Added by Nobuyoshi Nakada almost 3 years ago

  • test/ruby/test_module.rb: tests for [Bug #3422] and [Bug #3423].

Revision 33157
Added by Nobuyoshi Nakada over 2 years ago

  • insns.def (defineclass), vminsnhelper.c (vmgetcvarbase): see also inherited constants for classes without superclass and modules. [Bug #3423]

History

#1 Updated by Yuki Sonoda over 3 years ago

  • Target version set to 1.9.2

=begin

=end

#2 Updated by Yui NARUSE almost 3 years ago

  • Status changed from Open to Assigned
  • Assignee set to Yukihiro Matsumoto

#3 Updated by Hiroshi Nakamura almost 3 years ago

  • Target version changed from 1.9.2 to 1.9.3

#4 Updated by Yukihiro Matsumoto almost 3 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r32283.
Magnus, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • variable.c (rbconstget0): should not look for superclasses if the second optional argument is given for #constget(). fix [Bug #3422] [Bug #3423]

Also available in: Atom PDF