Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions stdlib/openssl/0/openssl.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -9332,7 +9332,8 @@ module OpenSSL
# Reads *length* bytes from the SSL connection. If a pre-allocated *buffer* is
# provided the data will be written into it.
#
def sysread_nonblock: (*untyped) -> untyped
def sysread_nonblock: (Integer length, ?String buffer, ?exception: true) -> String
| (Integer length, ?String buffer, exception: false) -> (String | :wait_readable | :wait_writable | nil)

# <!--
# rdoc-file=ext/openssl/ossl_ssl.c
Expand All @@ -9341,7 +9342,8 @@ module OpenSSL
# Writes *string* to the SSL connection in a non-blocking manner. Raises an
# SSLError if writing would block.
#
def syswrite_nonblock: (*untyped) -> untyped
def syswrite_nonblock: (_ToS string, ?exception: true) -> Integer
| (_ToS string, exception: false) -> (Integer | :wait_readable | :wait_writable | nil)
Comment on lines +9345 to +9346
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _ToS interface applies to all objects except BasicObject (e.g., nil, Hash, etc.). However, the actual implementation uses StringValue, and objects like nil should be excluded. I think string is appropriate.

And, Based on the implementation, syswrite_nonblock raises an error even when exception: false is specified. This is asymmetric to sysread_nonblock.
It seems there is no possibility of it returning nil.


# <!--
# rdoc-file=ext/openssl/lib/openssl/ssl.rb
Expand Down
9 changes: 6 additions & 3 deletions stdlib/socket/0/basic_socket.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ class BasicSocket < IO
# ### See
# * Socket#recvfrom
#
def recv_nonblock: (Integer maxlen, ?Integer flags, ?String buf, ?exception: boolish) -> (String | :wait_readable)
def recv_nonblock: (Integer maxlen, ?Integer flags, ?String buf, ?exception: true) -> String
| (Integer maxlen, ?Integer flags, ?String buf, exception: false) -> (String | :wait_readable)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the documentation states that Socket#recv_nonblock returns nil, there is a possibility that nil may be returned; the same may be true for recvmsg_nonblock and Socket#recvfrom_nonblock.


# <!--
# rdoc-file=ext/socket/lib/socket.rb
Expand Down Expand Up @@ -401,7 +402,8 @@ class BasicSocket < IO
# recvmsg_nonblock should not raise an IO::WaitReadable exception, but return
# the symbol <code>:wait_readable</code> instead.
#
def recvmsg_nonblock: (?Integer dlen, ?Integer flags, ?Integer clen, ?exception: boolish, ?scm_rights: boolish) -> ([ String, Addrinfo, Integer?, Array[Socket::AncillaryData] ] | :wait_readable)
def recvmsg_nonblock: (?Integer dlen, ?Integer flags, ?Integer clen, ?exception: true, ?scm_rights: boolish) -> [ String, Addrinfo, Integer?, Array[Socket::AncillaryData] ]
| (?Integer dlen, ?Integer flags, ?Integer clen, exception: false, ?scm_rights: boolish) -> ([ String, Addrinfo, Integer?, Array[Socket::AncillaryData] ] | :wait_readable)

# <!--
# rdoc-file=ext/socket/basicsocket.c
Expand Down Expand Up @@ -489,7 +491,8 @@ class BasicSocket < IO
# sendmsg_nonblock should not raise an IO::WaitWritable exception, but return
# the symbol <code>:wait_writable</code> instead.
#
def sendmsg_nonblock: (String mesg, ?Integer flags, ?Addrinfo | String dest_sockaddr, *Socket::AncillaryData controls, ?exception: boolish) -> (Integer | :wait_writable)
def sendmsg_nonblock: (String mesg, ?Integer flags, ?Addrinfo | String dest_sockaddr, *Socket::AncillaryData controls, ?exception: true) -> Integer
| (String mesg, ?Integer flags, ?Addrinfo | String dest_sockaddr, *Socket::AncillaryData controls, exception: false) -> (Integer | :wait_writable)

# <!--
# rdoc-file=ext/socket/basicsocket.c
Expand Down
9 changes: 6 additions & 3 deletions stdlib/socket/0/socket.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,8 @@ class Socket < BasicSocket
# ### See
# * Socket#accept
#
def accept_nonblock: (?exception: boolish) -> ([ Socket, Addrinfo ] | :wait_readable)
def accept_nonblock: (?exception: true) -> [ Socket, Addrinfo ]
| (exception: false) -> ([ Socket, Addrinfo ] | :wait_readable)

# <!--
# rdoc-file=ext/socket/socket.c
Expand Down Expand Up @@ -1105,7 +1106,8 @@ class Socket < BasicSocket
# ### See
# * Socket#connect
#
def connect_nonblock: (untyped addr, ?exception: untyped) -> (Integer | :wait_writable)
def connect_nonblock: (untyped addr, ?exception: true) -> Integer
| (untyped addr, exception: false) -> (Integer | :wait_writable)

# <!--
# rdoc-file=ext/socket/lib/socket.rb
Expand Down Expand Up @@ -1363,7 +1365,8 @@ class Socket < BasicSocket
# ### See
# * Socket#recvfrom
#
def recvfrom_nonblock: (Integer maxlen, ?Integer flags, ?untyped outbuf, ?exception: boolish) -> ([ String, Addrinfo ] | :wait_readable)
def recvfrom_nonblock: (Integer maxlen, ?Integer flags, ?untyped outbuf, ?exception: true) -> [ String, Addrinfo ]
| (Integer maxlen, ?Integer flags, ?untyped outbuf, exception: false) -> ([ String, Addrinfo ] | :wait_readable)

# <!--
# rdoc-file=ext/socket/socket.c
Expand Down
3 changes: 2 additions & 1 deletion stdlib/socket/0/tcp_server.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class TCPServer < TCPSocket
# * TCPServer#accept
# * Socket#accept
#
def accept_nonblock: (?exception: boolish) -> (TCPSocket | :wait_readable)
def accept_nonblock: (?exception: true) -> TCPSocket
| (exception: false) -> (TCPSocket | :wait_readable)

# <!--
# rdoc-file=ext/socket/tcpserver.c
Expand Down
3 changes: 2 additions & 1 deletion stdlib/socket/0/udp_socket.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class UDPSocket < IPSocket
# ### See
# * Socket#recvfrom
#
def recvfrom_nonblock: (Integer len, ?Integer flag, ?String outbuf, ?exception: boolish) -> [ String, [ String, Integer, String, String ] ]
def recvfrom_nonblock: (Integer len, ?Integer flag, ?String outbuf, ?exception: true) -> [ String, [ String, Integer, String, String ] ]
| (Integer len, ?Integer flag, ?String outbuf, exception: false) -> ([ String, [ String, Integer, String, String ] ] | :wait_readable)

# <!--
# rdoc-file=ext/socket/udpsocket.c
Expand Down
3 changes: 2 additions & 1 deletion stdlib/socket/0/unix_server.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class UNIXServer < UNIXSocket
# * UNIXServer#accept
# * Socket#accept
#
def accept_nonblock: (?exception: boolish) -> (UNIXSocket | :wait_readable)
def accept_nonblock: (?exception: true) -> UNIXSocket
| (exception: false) -> (UNIXSocket | :wait_readable)

# <!--
# rdoc-file=ext/socket/unixserver.c
Expand Down
Loading