Closed ehsantn closed 7 years ago
So is this about renaming an escaping variable? Can you give me an example of where you need to do this?
I don't think AstWalker ever goes into nested lambda expressions. We made a special case for replaceExprWithDict!
to explicitly deal with escaping variables. If this is the function you use in copy propagation, I can make it accommodate DomainLambda
too.
Wait, I believe replaceExprWithDict!
is already setup to handle DomainLambda
just fine. The relevant code is here. So copy propagation has to use replaceExprWithDict!
if it is not doing so.
replaceExprWithDict
is a special case. Is traversing DomainLambda's body fundamentally wrong?
I wouldn't say all nested traversals are wrong, but variable name clashing is a delicate matter and must be handled with care, which is often times specific to use scenario. So it is best not to generalize the logic into generic traversal code, as most traversals are not interested in nested case, and would be wrong otherwise if not handled carefully.
Ok, makes sense. I will use special code then.
AstWalkCallback
in DomainIR doesn't recurse inside the body. Therefore, AST walks like copy propagation don't go inside.