-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
When combining ruby2_keywords with alias_method or alias, arguments are not handled properly. This appears to require a built in function, since I'm not able to reproduce this with a normal function which I alias and redefine. The same issue occurs with both alias and alias_method.
Basic Repro:
class File
class << self
alias original_write write
ruby2_keywords def write(*args, &block)
puts "traced #{__method__}"
original_write(*args, &block)
end
end
end
File.write('scratch', "stuff", 0, mode: 'a+')
On MRI:
$ /usr/bin/ruby --version
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux-gnu]
$ /usr/bin/ruby test.rb
traced write
$
On JRuby:
$ jruby --version
jruby 9.4.8.0 (3.1.4) 2024-07-02 4d41e55a67 OpenJDK 64-Bit Server VM 11.0.15+0-adhoc..source on 11.0.15+0-adhoc..source +jit [x86_64-linux]
$ jruby test.rb
traced write
ArgumentError: wrong number of arguments (given 4, expected 2..3)
write at org/jruby/RubyIO.java:4290
write at temp.rb:7
<main> at temp.rb:13
$
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels