Project

General

Profile

Actions

Bug #530

closed

socket.c: TCPSocket registered with wrong arity

Added by mfurr (Mike Furr) about 16 years ago. Updated over 13 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
[ruby-core:18428]

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

Actions

Also available in: Atom PDF

Like0
Like0Like0