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
What is considered safe or not in the AST, is currently hardcoded in the SafeAnalysisNodeVisitor. For instance, a node that is an instance of ConstantExpression, is considered safe in all contexts. So when I'm creating my own expressions (that are safe by definition), I need to extend from ConstantExpression for the safe analysis to still work and the escaper node visitor not affecting the output.
In c44bd1f we're suddenly making assumptions about the class from outside. This will break child classes: In the above example a PrintNode wrapping a FooConstantExpression now gets converted to a TextNode ignoring the custom implementation.
How to deal with this? IMHO the ideal way would be to mark the ConstantExpression as @final and introduce an interface/flag for nodes, that marks them as safe in a certain or all contexts. Alternatively the optimizer should probably use get_class instead of instanceof.
The text was updated successfully, but these errors were encountered:
What is considered safe or not in the AST, is currently hardcoded in the
SafeAnalysisNodeVisitor
. For instance, a node that is an instance ofConstantExpression
, is considered safe in all contexts. So when I'm creating my own expressions (that are safe by definition), I need to extend fromConstantExpression
for the safe analysis to still work and the escaper node visitor not affecting the output.In c44bd1f we're suddenly making assumptions about the class from outside. This will break child classes: In the above example a
PrintNode
wrapping aFooConstantExpression
now gets converted to aTextNode
ignoring the custom implementation.How to deal with this? IMHO the ideal way would be to mark the
ConstantExpression
as@final
and introduce an interface/flag for nodes, that marks them as safe in a certain or all contexts. Alternatively the optimizer should probably useget_class
instead ofinstanceof
.The text was updated successfully, but these errors were encountered: