You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classAccountattr_reader email: String
attr_reader phone: String?
end
email always exists, but phone may be nil. So, a Ruby code accesing phone number needs to test if phone number exists explicitly.
account=Account.find(email)ifaccount.phone# Test if `phone` returns a `String`send_sms_to(account.phone)# Sending a SMS to the phone numberend
This doesn't work with Steep right now, because account.phone is a method call that may return different value in future. This proposal is to make it work by assuming pure methods returns the same value next time.
The text was updated successfully, but these errors were encountered:
I found that the invalidation of type refinements on method call cannot be safe.
a=[0]b=aifa[0].is_a?(Integer)# This refines the type to `Integer`a[0]=""# This invalidates a[0] refinementendifa[0].is_a?(String)# This refines the type to `String`b[0]=:foo# How about this!?!?end
I will consider dropping type refinements invalidation by method calls. 🤔
Will keep the invalidation on local variable assignments.
Proposal: https://hackmd.io/cQ75yJxcT_Ka5nHjQySWtg?view
Assume we have a class with the following RBS.
email
always exists, butphone
may benil
. So, a Ruby code accesing phone number needs to test if phone number exists explicitly.This doesn't work with Steep right now, because
account.phone
is a method call that may return different value in future. This proposal is to make it work by assuming pure methods returns the same value next time.The text was updated successfully, but these errors were encountered: