Skip to content

Recursive monotonic aggregates #7263

Answered by smowton
Ninja3047 asked this question in Q&A
Discussion options

You must be logged in to vote

You need to add the language[monotonicAggregates] modifier to the int depth(...) predicate.

Why? As set out in https://codeql.github.com/docs/ql-language-reference/expressions/#recursive-monotonic-aggregates, without the monotonic-aggregate semantics, on the second iteration of the algorithm the node a would be assigned a depth of 1, because its child b is known to have depth 0 and its child c hasn't been assigned a depth yet. Then on the third iteration it would be necessary to revise the depth of node a to 2 (and presumably to revise any parents of a that would get transient wrong answers). This isn't compatible with CodeQL's approach to recursion, which requires that the result set gro…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Ninja3047
Comment options

Answer selected by Ninja3047
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants