Actions
Feature #10773
closednested module should work in instance_eval
    Feature #10773:
    nested module should work in instance_eval
  
Status:
Rejected
Assignee:
-
Target version:
-
Description
see my code:
module M
  module M2
  end
end
class C
  include M
  def ivk_m2(*args, &blk)
    M2
  end
end
C.new.ivk_m2 # work
C.new.instance_eval do
  meth_in_m # work
  M2 # not work
end
and output
Uncaught exception: uninitialized constant M2
	/home/roroco/Dropbox/rbs/ro_btc/exe.rb:22:in `block in <top (required)>'
	/home/roroco/Dropbox/rbs/ro_btc/exe.rb:20:in `instance_eval'
	/home/roroco/Dropbox/rbs/ro_btc/exe.rb:20:in `<top (required)>'
in above code,  i think C.new.instance { M2 } should invoke M::M2 in syntax since it's in "instance block" or "main"
        
           Updated by roroco (roro co) almost 11 years ago
          Updated by roroco (roro co) almost 11 years ago
          
          
        
        
      
      my ruby version:
roroco@roroco ~ $ ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
my sys info:
roroco@roroco ~ $ lsb_release -a
No LSB modules are available.
Distributor ID:	LinuxMint
Description:	Linux Mint 17 Qiana
Release:	17
Codename:	qiana
        
           Updated by hsbt (Hiroshi SHIBATA) almost 11 years ago
          Updated by hsbt (Hiroshi SHIBATA) almost 11 years ago
          
          
        
        
      
      - Description updated (diff)
        
           Updated by ko1 (Koichi Sasada) almost 11 years ago
          Updated by ko1 (Koichi Sasada) almost 11 years ago
          
          
        
        
      
      Where is "meth_in_m"?
        
           Updated by shugo (Shugo Maeda) over 10 years ago
          Updated by shugo (Shugo Maeda) over 10 years ago
          
          
        
        
      
      - Status changed from Open to Rejected
It's an expected behavior that instance_eval doesn't affect constant lookup.
Constant lookup is designed to be as static as possible.
Actions