Project

General

Profile

Actions

Bug #17512

closed

ostruct super regression

Added by HParker (Adam Hess) 11 months ago. Updated 11 months ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:101939]

Description

In ruby 3.0, Calling super on ostruct always returns nil. This is a regression in ruby 3.0 introduced when fixing another issue.

introduced by:

This unintentionally changed super behavior in classes that inherit from OpenStruct.

require 'ostruct'

class Foo < OpenStruct
  def foo
    super
  end
end

p Foo.new(foo: 123).foo
Ruby 3.0:
=> nil
Ruby 2.7:
=> 123

Potential fix is to bring back some of the behavior reverted in issue #12136 to allow method missing to sometimes respond to methods with zero arguments.

This is implemented in: https://github.com/ruby/ruby/pull/4028 and included as a patch attached to this issue.


Files

0001-Allow-ostruct-to-return-a-value-on-super.patch (1.7 KB) 0001-Allow-ostruct-to-return-a-value-on-super.patch ostruct super patch HParker (Adam Hess), 01/05/2021 08:22 PM

Updated by hsbt (Hiroshi SHIBATA) 11 months ago

  • Assignee set to marcandre (Marc-Andre Lafortune)
  • Status changed from Open to Assigned

Updated by marcandre (Marc-Andre Lafortune) 11 months ago

  • Status changed from Assigned to Closed

Fixed and released as 0.3.2, thanks!

Actions

Also available in: Atom PDF