Issue #17726 has been reported by tenderlovemaking (Aaron Patterson).

----------------------------------------
Bug #17726: `respond_to_missing?` doesn't raise when called from `defined?`
https://bugs.ruby-lang.org/issues/17726

* Author: tenderlovemaking (Aaron Patterson)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.0dev (2021-03-16T19:10:11Z master 58660e9434) [x86_64-darwin20]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
I'm not sure whether or not this is expected behavior, but if `respond_to_missing?` is called from `defined?`, it won't raise an exception.

For example:

```ruby
class Foo
  def respond_to_missing?(*args)
    puts "hi"
    raise
  end
end
foo = Foo.new
p defined?(foo.bar)
```

If you run this program, the output is this:

```
$ ruby -v test.rb
ruby 3.1.0dev (2021-03-16T19:10:11Z master 58660e9434) [x86_64-darwin20]
hi
nil
```

But I would expect this to raise an exception.  Is the current behavior the desired behavior?

Thanks!



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>