ruby / rbs

Type Signature for Ruby
Other
1.91k stars 201 forks source link

inline type narrowing #1873

Open HoneyryderChuck opened 3 weeks ago

HoneyryderChuck commented 3 weeks ago

Not sure, but I think some variations with case-statement of this work, but this does not:


# considering a @io typed as TCPSocket | SSLSocket

if @io.is_a?(SSLSocket) && @io.verify_hostname(host)
# the last statement fails because `TCPSocket | SSLSocket` does not define verify_hostname, only the latter
ParadoxV5 commented 3 weeks ago

Type checker limitation?

We can aid this for all checkers with