-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Ruby: Reimplement flow through captured variables using field flow #11725
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
d4f1208
to
5e11ea7
Compare
5e11ea7
to
27e0034
Compare
27e0034
to
e379e31
Compare
e379e31
to
a2cc202
Compare
b7d1941
to
eaf1b5c
Compare
eaf1b5c
to
abce224
Compare
abce224
to
b04fd1c
Compare
a3f3886
to
3480fb9
Compare
7afc01d
to
d018b80
Compare
d018b80
to
b68b332
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.
Haven't done a full review, just posting my comments so far
c6815e7
to
fe52878
Compare
#14048 has been merged, which will conflict with this PR. Apologies for the disruption. |
No worries; I'll update. |
fe52878
to
d259c89
Compare
d259c89
to
a06a9ff
Compare
@@ -331,6 +443,7 @@ private module Cached { | |||
p instanceof SplatParameter | |||
} or | |||
TSelfParameterNode(MethodBase m) or | |||
TLambdaSelfParameterNode(Callable c) { lambdaCreationExpr(_, _, c) } or |
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.
I think we should rename this to TLambdaSelfReferenceNode
. As it stands it sounds too much like it's related to the self
parameter somehow, which it isn't.
Blocks can actually receive a self
argument that overrides its captured view of self
. When and if we add support for that, we'll need an actual self
parameter for lambdas, and then this name will just get even more confusing.
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.
You mean for blocks passed to module_eval
and similar methods?
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.
@aibaars Yes, module_eval
, class_eval
, instance_eval
, or any method that that passes its block to one of those methods, such as RSpec.describe
in a test or rescue_from
in an action controller.
This PR adopts the shared variable capture flow library in Ruby.
The new results reported by DCA are a result of the fact that we are now also able to track side-effects on captured variables, such as writes to instance fields inside blocks. The lost results (those that I have checked) are FPs resulting from the old jump-step based modeling, where data could flow in through one callable and out via another.
The implementation is similar to Java (see PR above), except I chose to distinguish "lambda
self
" from "normalself
". This is becauseself
can actually be referenced from within lambdas (as a captured variable):