[#102393] [Ruby master Feature#17608] Compact and sum in one step — sawadatsuyoshi@...

Issue #17608 has been reported by sawa (Tsuyoshi Sawada).

13 messages 2021/02/04

[#102438] [Ruby master Bug#17619] if false foo=42; end creates a foo local variable set to nil — pkmuldoon@...

Issue #17619 has been reported by pkmuldoon (Phil Muldoon).

10 messages 2021/02/10

[#102631] [Ruby master Feature#17660] Expose information about which basic methods have been redefined — tenderlove@...

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

9 messages 2021/02/27

[#102639] [Ruby master Misc#17662] The herdoc pattern used in tests does not syntax highlight correctly in many editors — eregontp@...

Issue #17662 has been reported by Eregon (Benoit Daloze).

13 messages 2021/02/27

[#102652] [Ruby master Bug#17664] Behavior of sockets changed in Ruby 3.0 to non-blocking — ciconia@...

Issue #17664 has been reported by ciconia (Sharon Rosner).

23 messages 2021/02/28

[ruby-core:102351] [Ruby master Bug#17509] Custom respond_to? methods in modules break defined?(super)

From: naruse@...
Date: 2021-02-01 10:17:55 UTC
List: ruby-core #102351
Issue #17509 has been updated by naruse (Yui NARUSE).

Backport changed from 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONTNEED, 3.0: REQUIRED to 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONTNEED, 3.0: DONE

ruby_3_0 147453ad1e85bc94506c269e363e736675946908 merged revision(s) 85b5d4c8bf4cdcba4f1af65f2bc0c8ac716cb795.

----------------------------------------
Bug #17509: Custom respond_to? methods in modules break defined?(super)
https://bugs.ruby-lang.org/issues/17509#change-90211

* Author: benediktdeicke (Benedikt Deicke)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONTNEED, 3.0: DONE
----------------------------------------
When using `defined?(super)` to check that a superclass method exists before calling `super`, including modules with a custom `respond_to?` method seems to break the check so it wrongfully returns a truthy value, even though the superclass method doesn't exist.

This only happens on Ruby 3.0.0 and works fine on previous Ruby versions. This is possibly related to this change: https://github.com/ruby/ruby/pull/3777

### Example 

```ruby
module SomeModule
  def a_method
    defined?(super) ? super : :no_super_method
  end
end

module RespondModule
  def respond_to?(*)
    super
  end
end

class PlainClass
  include SomeModule
end

class ModuleClass
  include RespondModule
  include SomeModule
end

puts "PlainClass: #{PlainClass.new.a_method}"
puts "ModuleClass: #{ModuleClass.new.a_method}"
```

### Actual Result on Ruby 3.0.0p0

```
PlainClass: no_super_method
test.rb:3:in `a_method': super: no superclass method `a_method' for #<ModuleClass:0x00007fd77383f908> (NoMethodError)
Did you mean?  method
	from test.rb:24:in `<main>'
```

### Expected Result (like on older versions)

```
PlainClass: no_super_method
ModuleClass: no_super_method
```

Thanks to Rafael Fran軋 for helping me unravel this. 

---Files--------------------------------
test.rb (359 Bytes)


-- 
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>

In This Thread

Prev Next