Ruby Forum Ruby-core > defined?

Posted by ts (Guest)
on 21.04.2008 10:29
(Received via mailing list)
Sorry but I don't completely agree with this patch

  * compile.c (defined_expr): capture exception during defined?
    evaluation.  a patch from wanabe <s.wanabe at gmail.com> in
    [ruby-dev:34461].  [ruby-core:16010]

 In [ruby-core:16010] there are 3 problems with defined?

 * what I call "empty NODE_BEGIN"

vgs% ./ruby -ve 'def self.a=() end; p defined?(self.a=())'
ruby 1.9.0 (2008-04-21 revision 16121) [i686-linux]
nil
vgs%

 See the difference with

vgs% ./ruby -ve 'def self.a=() end; p defined?(self.a=(12))'
ruby 1.9.0 (2008-04-21 revision 16121) [i686-linux]
"method"
vgs%

 * the patch fix only this case

vgs% ./ruby -ve 'def a() end; p defined?(a(1).a)'
ruby 1.9.0 (2008-04-21 revision 16121) [i686-linux]
nil
vgs%


 * but it don't fix this problem

vgs% ./ruby -ve 'def a(x) end; p defined?(a::B)'
ruby 1.9.0 (2008-04-21 revision 16121) [i686-linux]
-e:1:in `<main>': wrong number of arguments (0 for 1) (ArgumentError)
vgs%


 I've volontary given these 3 examples, in [ruby-core:16010],
 because I don't wanted to have a partial patch :-)



Guy Decoux