-
Notifications
You must be signed in to change notification settings - Fork 558
flow-sensitivity should understand instance_of? (or we should warn about it) #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This makes sure that, after calling `instance_of?` on an object, Sorbet knows about the type. Fixes #48
Taking a stab at this... For completeness-sake, this is how I reproduced the issue: # typed: true
class A; end
def main
a = T.let(A.new, T.any(A, Float))
if a.is_a?(A)
T.assert_type!(a, A)
end
if a.instance_of?(A)
T.assert_type!(a, A)
end
end Output:
Expected: No errors Note that |
My original attempt won't work (as seen in #3364). The basic reason is that we can't make assumptions for |
* Add two extern special-cases (rb_int_powm, rb_f_send) * Explicit whitelist of methods to export * Ensure sorted output order * Better printing information * Ignore -2 calling convention * Don't clang-format WrappedIntrinsics.h * Add whitelist of valid SymbolRefs * Make patch regex more strict * (cd compiler/IREmitter/Intrinsics/ && make)
https://ruby-doc.org/core-2.4.3/Object.html#method-i-instance_of-3F looks to be a synonym for {{is_a?}}
@btidor-stripe just ran into this and was confused
Originally reported by @nelhage-stripe at https://jira.corp.stripe.com/browse/RUBYPLAT-1371
The text was updated successfully, but these errors were encountered: