Repository navigation
Add missing signatures to socket - #3217
Merged
Merged
Conversation
- Add `Socket::ResolutionError` - Add `Socket::Option` - Add `Socket.tcp_fast_fallback` and `Socket.tcp_fast_fallback=` - Fix `BasicSocket#getsockopt` to return `Socket::Option`, and let `BasicSocket#setsockopt` accept a `Socket::Option` Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Replace the hand-written comments with the ones generated from RDoc. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The `0` is just the success code of setsockopt(2) and is not documented as a return value, so callers should not rely on it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fill in classes and methods that
socketwas missing, found by diffing the runtime (ObjectSpace/instance_methods(false)) against the loaded RBS environment.Socket::ResolutionError(#error_code, Ruby 3.3+)Socket::Option(.new,.bool,.byte,.int,.linger,.ipv4_multicast_*, and the matching instance methods)Socket.tcp_fast_fallback/Socket.tcp_fast_fallback=(Ruby 3.4+)BasicSocket#getsockopt: it returnedInteger | boolish | Stringbut actually returnsSocket::OptionBasicSocket#setsockopt: add the(Socket::Option)form (the return type staysvoid)Intentionally not added:
Socket::HostnameResolutionResult,Socket::HostnameResolutionStoreandAddrinfo#connect_internal, which are internal toSocket.tcp.Notes
getsockoptnow returnsSocket::Option, so code that treated the result asIntegerorStringwill see different type errors.Optionhas#unpack,#int,#bool, etc.Socket.tcp_fast_fallback=stores any object as is, but is typed(bool)to keep the getter'sboolreturn sound.Test plan
test/stdlib/socket/*_test.rb(27 tests) pass withLC_ALL=en_US.UTF-8rbs -rsocket validatebin/steep check🤖 Generated with Claude Code