Project

General

Profile

Bug #6239

super Does Not Pass Modified Rest Args When Originally Empty

Added by mudge (Paul Mucur) over 8 years ago. Updated over 8 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
1.8.7-p358
[ruby-core:44015]

Description

Given the following code:

class A
  def a(*args)
    args
  end
end

class B < A
  def a(*args)
    args << "foo"

    super
  end
end

1.8.7-p358> B.new.a("bar")
=> ["bar", "foo"]
1.8.7-p358> B.new.a
=> []

But:

1.9.2-p290> B.new.a("bar")
=> ["bar", "foo"]
1.9.2-p290> B.new.a
=> ["foo"]

The 1.9.2 behaviour is more predictable than 1.8.7, should this be backported or is this expected behaviour?

Updated by mudge (Paul Mucur) over 8 years ago

As a side note, both JRuby 1.6.6 and Rubinius 1.2.4 in 1.8 compatibility mode follow the behaviour of 1.9.2.

James Hunt and I have filed a pull request to the RubySpec project to document this issue at: https://github.com/rubyspec/rubyspec/pull/130

Updated by matz (Yukihiro Matsumoto) over 8 years ago

  • Status changed from Open to Rejected

It's behavior change in 1.9, and we are not going to change the behavior in 1.8 (other than fixing bugs) any more.

Matz.

Updated by marcandre (Marc-Andre Lafortune) over 8 years ago

Hi Matz

matz (Yukihiro Matsumoto) wrote:

It's behavior change in 1.9, and we are not going to change the behavior in 1.8 (other than fixing bugs) any more.

Oh, it is?

So you mean that it was a known fact that there was an exceptional case with super and modified rest argument only when that rest argument was empty? And that it was a "feature"? Was there any rationale for that behavior?

I'm not saying the bug must be fixed, as it can be easily circumvented using explicit arguments, but it definitely looks like a bug to me.

Updated by matz (Yukihiro Matsumoto) over 8 years ago

Hi,

It has not been considered as a bug. The old document described this
behavior. Ko1 asked me to allow behavioral change in 1.9, and I admit.

                        matz.

In message "Re: [ruby-core:44023] [Ruby 1.8 - Bug #6239] super Does Not Pass Modified Rest Args When Originally Empty"
on Sun, 1 Apr 2012 03:20:18 +0900, "marcandre (Marc-Andre Lafortune)" ruby-core@marc-andre.ca writes:

|matz (Yukihiro Matsumoto) wrote:
|> It's behavior change in 1.9, and we are not going to change the behavior in 1.8 (other than fixing bugs) any more.
|
|Oh, it is?
|
|So you mean that it was a known fact that there was an exceptional case with super and modified rest argument only when that rest argument was empty? And that it was a "feature"? Was there any rationale for that behavior?
|
|I'm not saying the bug must be fixed, as it can be easily circumvented using explicit arguments, but it definitely looks like a bug to me.

Updated by mudge (Paul Mucur) over 8 years ago

Thank you, Matz.

We have now covered this behaviour in RubySpec as of https://github.com/rubyspec/rubyspec/commit/ffb634f3899dfc0d8a494afa8c754992041ddb2e

Also available in: Atom PDF