Commit 5ef2a90
committed
Fix rest arg recording in IRClosure (long commit msg for a 1 line-fix)
* Recording a rest arg for blocks involved creating a splat (just
like in a method). However, the unsplat flag wasn't being set
in IRClosure (unlike in a method).
* This bug only affected zsuper in a block that used by define_method.
See output on example enclosed further below in master vs 1.7 ...
zsuper from foo and bar emit different output which is broken.
However, zsuper in define_method is no longer supported in
Ruby 2.x, it appears. MRI throws the following RuntimeError:
"implicit argument passing of super from method defined by define_method() is not supported. Specify all arguments explicitly. (RuntimeError)"
So, this bug (or bugfix) is not really relevant anymore. Hence,
I am not adding a test/spec to document this behavior, but including
a test snippet for it in the commit message.
We should simply get rid of this support and simplify the zsuper
logic in the IRBuilder.
* I am fixing this here so I can work on #2409 and implement a clean fix
without worrying about different behavior for methods and closures.
--------------------------
class C
def foo(a, *b)
p "foo-a: #{a}; foo-b[0]: #{b[0]}"
end
def bar(a, *b)
p "bar-a: #{a}; bar-b[0]: #{b[0]}"
end
end
class D < C
def self.doit(&blk)
define_method :foo, blk
end
def bar(a, *b)
super
end
end
D.doit { |a, *b| super }
d = D.new
d.bar(1, 2, 3)
d.foo(1, 2, 3)
--------------------------
[subbu@earth ir] jruby /tmp/bug.rb
"bar-a: 1; bar-b[0]: 2"
"foo-a: 1; foo-b[0]: [2, 3]"
--------------------------1 parent 0562581 commit 5ef2a90
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
| 198 | + | |
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| |||
0 commit comments