You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The base Visitor implements the scope logic that defines when a new scope is opened or an existing one is closed. The scopes build a hierarchy, i.e., scopes are linked with each other while a scope refers to an outer scope and one or multiple nested scopes. This hierarchy is determined while visiting the statements, hence it is important that the classes call the base Visitor's visit method.
The initial design did not take into account that moving nodes may require updating the scope hierarchy. This is important as searching for a variable's value may otherwise fail if a variable declared in an outer scope cannot be found.
Also, sometimes nodes are visited out of order, for example, during partial loop unrolling in the CompileTimeExpressionSimplifier. This was not considered either. As an example, look into the doPartialLoopUnrolling method that moves the For loop's initializer into a Block but visits the initializer directly by skipping the block statement. This causes a wrongly assigned variable scope (but does not lead to break partial unrolling).
The text was updated successfully, but these errors were encountered:
This has been resolved in v2.0, where there are now functions ScopedVisitor::enterScope, ScopedVisitor::visitChildren and ScopedVisitor::exitScope that can be used by Visitors derived from the basic visitor to manually decide when to enter/not enter a scope. This doesn't eliminate the possibility of these kinds of issues occurring, but it does provide the tool to prevent and/or fix them.
The base
Visitor
implements the scope logic that defines when a new scope is opened or an existing one is closed. The scopes build a hierarchy, i.e., scopes are linked with each other while a scope refers to an outer scope and one or multiple nested scopes. This hierarchy is determined while visiting the statements, hence it is important that the classes call the baseVisitor
'svisit
method.The initial design did not take into account that moving nodes may require updating the scope hierarchy. This is important as searching for a variable's value may otherwise fail if a variable declared in an outer scope cannot be found.
Also, sometimes nodes are visited out of order, for example, during partial loop unrolling in the CompileTimeExpressionSimplifier. This was not considered either. As an example, look into the
doPartialLoopUnrolling
method that moves the For loop's initializer into aBlock
but visits the initializer directly by skipping the block statement. This causes a wrongly assigned variable scope (but does not lead to break partial unrolling).The text was updated successfully, but these errors were encountered: