Project

General

Profile

Actions

Bug #530

closed

socket.c: TCPSocket registered with wrong arity

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

Status:
Rejected
Priority:
Normal
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 #1

Updated by matz (Yukihiro Matsumoto) about 13 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

Actions #2

Updated by matz (Yukihiro Matsumoto) about 13 years ago

  • Status changed from Open to Rejected

=begin

=end

Actions

Also available in: Atom PDF