From: Yusuke ENDOH Date: 2010-02-13T20:59:40+09:00 Subject: [ruby-core:28167] Re: [Feature #2740] Extend const_missing to pass in the nesting Hi, 2010/2/13 Yehuda Katz : > > 1. It changes the const_missing API, breaking code. It would be nice to > > find a way around this. > > A simple arity check will get around this issue. It's ugly. The core should avoid such a dirty hack when possible. I also think it would be nice to find another clean API. > I have attached a patch that makes nesting available in const_missing if the const_missing method has an arity other than 1. It causes SEGV. $ ./miniruby -e ' class C def self.const_missing(id, nesting) p id, nesting end end C.enum_for(:const_get, :D).next ' [BUG] Segmentation fault ruby 1.9.2dev (2010-02-13 trunk 26659) [i686-linux] -- control frame ---------- c:0005 p:---- s:0009 b:0009 l:000008 d:000008 CFUNC :nesting c:0004 p:---- s:0007 b:0007 l:000006 d:000006 CFUNC :const_get c:0003 p:---- s:0005 b:0005 l:000004 d:000004 CFUNC :each c:0002 p:---- s:0003 b:0003 l:002168 d:000002 IFUNC c:0001 p:---- s:0001 b:-001 l:000000 d:000000 ------ --------------------------- -- Ruby level backtrace information ---------------------------------------- -e:0:in `each' -e:0:in `const_get' -e:0:in `nesting' -- C level backtrace information ------------------------------------------- ./miniruby(rb_vm_bugreport+0xbd) [0x81a5c6d] ./miniruby [0x808e69e] ./miniruby(rb_bug+0x28) [0x808e758] ./miniruby [0x813a6b0] [0xffffe40c] ./miniruby(rb_vm_cref+0x38) [0x8193d88] ./miniruby [0x8090dc4] ./miniruby [0x819d889] ./miniruby(rb_funcall+0x92) [0x819e142] ./miniruby [0x817d571] ./miniruby [0x80db78c] ./miniruby [0x8191bfd] ./miniruby [0x819d889] ./miniruby [0x81a1c2e] ./miniruby(rb_iterate+0xac) [0x8191dac] ./miniruby(rb_block_call+0x3f) [0x8191f3f] ./miniruby [0x808c0d9] ./miniruby [0x819d889] ./miniruby [0x81a1c2e] ./miniruby(rb_iterate+0xac) [0x8191dac] ./miniruby(rb_block_call+0x3f) [0x8191f3f] ./miniruby [0x808c162] ./miniruby [0x8195d5b] ./miniruby(rb_vm_invoke_proc+0x76) [0x819c816] ./miniruby(rb_fiber_start+0x1d2) [0x81aed52] ./miniruby [0x8091479] ./miniruby(ruby_run_node+0x32) [0x8092c92] ./miniruby(main+0x5a) [0x805a8da] /lib/i686/cmov/libc.so.6(__libc_start_main+0xe5) [0xb7d89455] ./miniruby [0x805a7e1] [NOTE] You may have encountered a bug in the Ruby interpreter or extension libraries. Bug reports are welcome. For details: http://www.ruby-lang.org/bugreport.html Aborted -- Yusuke ENDOH