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
QL-for-QL: Add a redundant aggregate query #7472
base: main
Are you sure you want to change the base?
Conversation
5e2883f
to
09b2be1
| * Holds if `aggr` is a redundant aggregate. | ||
| * The aggregate declares a single variable `var`, the value of which is `operand`, and it is only used in `formula`. | ||
| */ | ||
| predicate redundatAggregate(AstNode aggr, AstNode formula, VarDecl var, AstNode operand) { |
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.
Random question, would this also consider rewriting aggregates as inline casts, e.g.
exists(Type t | t = foo())
into
foo().(Type)
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.
It doesn't currently, but it could.
Your example would become foo() instanceof Type as exists(..) is a formula and not an expression.
(any(Type t | t = foo()) would become foo().(Type)).
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.
And I've done it.
The patch is grouped together with the original.
But if you check out the run the redundant-aggregate patch commit you'll see plenty of exists(Type t | t = foo()) getting simplified.
If the added type-cast itself would be redundant then I don't emit a type-cast.
(For the above that would be the case if the type of foo() is Type, in that case it simplifies to exists(foo())).
…thus an exists might not be redundant (caused non-monotonic recursion for Python)
Inspired by #5160
And I tried to automatically fix all instances (except the cases where there is a comment in the middle).
This PR is currently a test, it should not necessarily be merged.
The text was updated successfully, but these errors were encountered: