Bug #6239
closed
super Does Not Pass Modified Rest Args When Originally Empty
Added by mudge (Paul Mucur) over 12 years ago.
Updated over 12 years ago.
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?
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
- 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.
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.
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.
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0