Project

General

Profile

Actions

Bug #3422

closed

Object.const_get(:A, false) can access BasicObject::A

Added by judofyr (Magnus Holm) almost 14 years ago. Updated about 11 years ago.

Status:
Closed
Target version:
ruby -v:
-
Backport:
[ruby-core:30719]

Description

=begin
From the documentation of Module#const_get(sym, inherit=true):

If the constant is not defined or is defined by the ancestors and inherit is false, NameError will be raised.

Yet, this works fine:

BasicObject::A = 1
Object.const_get(:A, false) # => 1

While I haven't tested it, I believe the attached patch should fix the issue.
=end


Files

patch.diff (417 Bytes) patch.diff Patch judofyr (Magnus Holm), 06/11/2010 04:11 AM

Related issues 3 (0 open3 closed)

Is duplicate of Ruby master - Bug #3423: Inconsistent behaviour of Module#const_get with included modulesClosedmatz (Yukihiro Matsumoto)06/11/2010Actions
Has duplicate Ruby master - Bug #5143: include not properly registering modular methodsClosed08/02/2011Actions
Has duplicate Ruby master - Bug #5154: method_missing and module scope, regression in 1.9.3Closedmatz (Yukihiro Matsumoto)08/03/2011Actions

Updated by naruse (Yui NARUSE) over 12 years ago

  • Status changed from Open to Assigned
  • Assignee set to matz (Yukihiro Matsumoto)
  • Target version set to 1.9.3

Updated by matz (Yukihiro Matsumoto) over 12 years ago

the patch should be applied before 1.9.3.

matz.

Updated by matz (Yukihiro Matsumoto) over 12 years ago

Sorry, this issue must be covered by #3423.

matz.

Actions #4

Updated by matz (Yukihiro Matsumoto) over 12 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 (rb_const_get_0): should not look for superclasses if
    the second optional argument is given for #const_get().
    fix [Bug #3422] [Bug #3423]

Updated by naruse (Yui NARUSE) over 12 years ago

  • Status changed from Closed to Assigned
  • Priority changed from 3 to Normal

r32283 breaks following codes:

module LangModuleSpecInObject
module LangModuleTop
end
end
include LangModuleSpecInObject
module LangModuleTop
end #=> NameError: uninitialized constant LangModuleTop

class BasicObject
end #=> NameError: uninitialized constant BasicObject

Updated by naruse (Yui NARUSE) over 12 years ago

  • Status changed from Assigned to Closed

Yui NARUSE wrote:

r32283 breaks following codes:

Oops, r32342 fix this. thanks!

Updated by naruse (Yui NARUSE) over 12 years ago

  • Status changed from Closed to Assigned

Following code still doesn't work:

module LangModuleSpecInObject
module LangModuleTop
end
end
include LangModuleSpecInObject
p LangModuleTop
end
p LangModuleSpecInObject::LangModuleTop == LangModuleTop #=> false (it should be true)

Updated by matz (Yukihiro Matsumoto) over 12 years ago

Can you elaborate?

If I remove "end" in the line 7, it works for me (otherwise, it was an syntax error).

matz.

Updated by naruse (Yui NARUSE) over 12 years ago

Oh sorry, it must be:

module LangModuleSpecInObject
module LangModuleTop
end
end
include LangModuleSpecInObject
module LangModuleTop
end
p LangModuleSpecInObject::LangModuleTop == LangModuleTop

Updated by kosaki (Motohiro KOSAKI) over 12 years ago

Oh sorry, it must be:

module LangModuleSpecInObject
module LangModuleTop
end
end
include LangModuleSpecInObject
module LangModuleTop
end
p LangModuleSpecInObject::LangModuleTop == LangModuleTop

matz, could you please answer to Yui?

Updated by kosaki (Motohiro KOSAKI) over 12 years ago

Matz, I think we need to decide either 1) revert r32283 or 2) fix naruse reported regression. Everybody know you are busy. But I believe 1.9.3 have no regression.....

Updated by nobu (Nobuyoshi Nakada) over 12 years ago

  • Status changed from Assigned to Closed

Updated by judofyr (Magnus Holm) over 12 years ago

On Sat, Sep 3, 2011 at 04:57, Nobuyoshi Nakada wrote:

Issue #3422 has been updated by Nobuyoshi Nakada.

Status changed from Assigned to Closed

Why is this issue closed? Is the current behaviour acceptable?

Updated by kosaki (Motohiro KOSAKI) over 12 years ago

  • ruby -v changed from ruby 1.9.2dev (2010-05-31 revision 28117) [x86_64-darwin10.3.0] to -

Why is this issue closed? Is the current behaviour acceptable?

Can you still reproduce this issue?

Updated by judofyr (Magnus Holm) over 12 years ago

Why is this issue closed? Is the current behaviour acceptable?

Can you still reproduce this issue?

Not the original issue. But it seemed to me that this issue was left
open because it introduced other problems (discussed above). Now that
this one has closed, I'm wondering what happened to this new issue?

Updated by naruse (Yui NARUSE) over 12 years ago

  • ruby -v changed from - to ruby 1.9.2dev (2010-05-31 revision 28117) [x86_64-darwin10.3.0]

nobu lazily closed this ticket without the revision reference: r33163.

Updated by kosaki (Motohiro KOSAKI) over 12 years ago

  • ruby -v changed from ruby 1.9.2dev (2010-05-31 revision 28117) [x86_64-darwin10.3.0] to -

Why is this issue closed? Is the current behaviour acceptable?

Can you still reproduce this issue?

Not the original issue. But it seemed to me that this issue was left
open because it introduced other problems (discussed above). Now that
this one has closed, I'm wondering what happened to this new issue?

As Yui explained, nobu fixed and commited it into ruby_1_9_3 branch. so
I'm not thinking the regression above discussed disappeared. If you run
latest ruby_1_9_3 branch and find any issue, please let us know asap.

Thank you for paying attention our bugfixes effort.

Updated by aef (Alexander E. Fischer) over 11 years ago

Could the following problem be related to this change? "Including namespace module through RSpec config in Ruby 1.9.3":http://stackoverflow.com/questions/13042298/including-namespace-module-through-rspec-config-in-ruby-1-9-3

If so, wouldn't it be a better idea to revert this?

Updated by kosaki (Motohiro KOSAKI) over 11 years ago

  • Status changed from Closed to Open

Updated by mame (Yusuke Endoh) over 11 years ago

  • Status changed from Open to Assigned
  • Target version changed from 1.9.3 to 2.0.0

Matz, do you think that it should be changed again?
IMO, in principle, I don't think that it is a good idea to change the behavior so many times.

--
Yusuke Endoh

Updated by shugo (Shugo Maeda) about 11 years ago

  • Assignee changed from matz (Yukihiro Matsumoto) to kosaki (Motohiro KOSAKI)

mame (Yusuke Endoh) wrote:

Matz, do you think that it should be changed again?
IMO, in principle, I don't think that it is a good idea to change the behavior so many times.

I'm not sure why this ticket has been reopened, but if it's because of the following comment, this ticket can be closed, because the request has already been rejected in #7213.

Could the following problem be related to this change? "Including namespace module through RSpec config in Ruby 1.9.3":http://stackoverflow.com/questions/13042298/including-namespace-module-through-rspec-config-in-ruby-1-9-3

If so, wouldn't it be a better idea to revert this?

Kosaki-san, why did you reopen this ticket?

Updated by kosaki (Motohiro KOSAKI) about 11 years ago

  • Status changed from Assigned to Closed

Kosaki-san, why did you reopen this ticket?

Sorry, my memory was lost and I don't remember why. but I suspect your guess is right and we can close this ticket.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0