-
Notifications
You must be signed in to change notification settings - Fork 565
Make runtime type check attr_accessor
writers
#6426
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
Conversation
582988d
to
ded6761
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks neat, thanks! I'll have to test it on Stripe's codebase to make sure. I'd prefer to do that after the implementation is adjusted to use the alternate current_declaration
strategy you mentioned.
ded6761
to
78b052a
Compare
Thank you, happy to finally get this working. Also forgot to thank @XrXr for giving me the original idea to check the
I think this is ready to run that check, though I suspect this might turn up some unexpected cases at runtime since |
78b052a
to
5747dcf
Compare
@jez I am curious about what this is going to unearth in the Stripe codebase. Did you have any time to run it at all? |
Sorry I haven't had a chance to test it. My guess is that it's going to expose a bunch of people either passing in mocked values or I should have some time to test this today though, so I will get back to you. |
The first build failed with thousands of test failures 😢 I will take some time to try to figure out whether they all share a couple common causes, or what might be required to fix them all. |
Heads up Ufuk, I'm going to hijack your PR to leave some documentation for posterity in the next comment. (I just want to get a permalink that I can paste into some comments in Stripe's codebase—the comment itself is not addressed to you.) |
👋 Hey there! If you're reading this, it likely means that you're looking at some The PR whose comments you're reading right now fixes a bug in Sorbet where Sorbet previously did not wrap the writer method defined by To allow the Sorbet version to be upgraded, instead of fixing the root causes, we have simply rewritten the If you are seeing this in your code, feel free to either add a sig to the If you have questions, feel free to reach out. |
It turns out that all the test failures blamed back to 5 individual |
Thanks! This one has been broken for a long time, great to see it fixed. |
Thank you very much for fixing this issue! ❤️ |
Sorbet runtime has never checked the writer for
attr_accessor
defined methods since that is the only case where a single signature needs to be matched up to two methods.This PR adds an exception for the reader method of an
attr_accessor
triggered method added handling. For those cases, after we clear the current declaration, we create a new writer declaration with the correct params and make it the current declaration. That makes sure that the next method added handling, which should be for the writer method, can find and process a correct declaration.Credit to @XrXr for giving me the original idea to check the
caller_location
label to see if we are in anattr_accessor
call or not.Motivation
Fixes: #5685
Test plan
Extended existing automated tests, and removed a
TODO
.