-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Ruby: Synthesize implicit super arguments #19206
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
a0ecc47
to
3d4ab0e
Compare
3d4ab0e
to
65a1198
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 plausible to me, but there are many changed files, so let me try to summarize my understanding and we can move forward if it is adequate:
- We wish to synthesize arguments for super calls, these can take a variety of forms including symbols, pairs and splat arguments.
- Some of these forms, we do not yet synthesize, so they are granted a new base class, FormImpl with a FormReal and a FormSynth extension. Each of these get their own branch.
- In a number of places referencing Form, we now have to choose either the real, the synthesized or both (a few places simply exclude the synth)
TSynthKind
has been given a real class- The actual synthesis is happening in
ImplicitSuperArgsSynthesis
together with the newImplicitSuperBlockArgumentNode
- Also, the position is now tracked for parameter assignments. I am not sure if this is needed for the semantics or if it is just an optimisation.
Absolutely correct.
The only reason why the predicates in |
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.
LGTM
Ah, to know how to match up parameters and arguments, I take it. |
Inspired by #19164, this PR synthesizes implicit
super
arguments. For example, inwe synthesize arguments in the call to
super
so that it actually becomessuper(y, *rest, k: k, **kwargs)
. We additionally also synthesize an implicit block argument, but that only pertains to data flow.The benefit of doing it in the AST synthesis layer is that all logic that builds on top (like control flow, SSA, data flow) automatically benefits.
DCA for the default suite shows that we gain a few new results (as expected), and DCA for a custom suite shows that we remove FPs for
rb/unused-parameter
andrb/useless-assignment-to-local
(also as expected).