Bug #530
closedsocket.c: TCPSocket registered with wrong arity
Description
=begin
The C code for TCPSocket#initialize does not register it with the correct arity. Therefore, reflective methods return incorrect information:
irb(main):001:0> require 'socket'
=> true
irb(main):002:0> TCPSocket.method(:initialize).arity
=> -1
irb(main):003:0> TCPSocket.new
ArgumentError: wrong number of arguments (0 for 2)
from (irb):3:in initialize' from (irb):3:in
new'
from (irb):3
The culprit seems to be in ext/socket/socket.c:3943
rb_define_method(rb_cTCPSocket, "initialize", tcp_init, -1);
should be
rb_define_method(rb_cTCPSocket, "initialize", tcp_init, -3);
=end
Updated by matz (Yukihiro Matsumoto) about 16 years ago
=begin
The methods implemented in C dispatches their arguments by themselves, so that arity for them always gives -1. It's a restriction, but not a bug.
=end
Updated by matz (Yukihiro Matsumoto) about 16 years ago
- Status changed from Open to Rejected
=begin
=end