Skip to content

Commit 9be1f2d

Browse files
committed
PS: Replace another 'forex' with explicit recursion.
1 parent 8664842 commit 9be1f2d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

powershell/ql/lib/semmle/code/powershell/dataflow/internal/DataFlowPrivate.qll

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,21 @@ class NamedSet extends NamedSet0 {
523523
not exists(result.getNamedArgument(_))
524524
}
525525

526+
pragma[nomagic]
527+
private Function getAFunctionRec(int i) {
528+
i = 0 and
529+
result.getAParameter().getLowerCaseName() = this.getRankedName(0)
530+
or
531+
exists(string name |
532+
pragma[only_bind_into](name) = this.getRankedName(i) and
533+
result.getAParameter().getLowerCaseName() = pragma[only_bind_into](name) and
534+
result = this.getAFunctionRec(i - 1)
535+
)
536+
}
537+
526538
/** Gets a function that has a parameter for each name in this set. */
527539
Function getAFunction() {
528-
forex(string name | name = this.getAName() | result.getAParameter().matchesName(name))
540+
result = this.getAFunctionRec(this.getSize() - 1)
529541
or
530542
this.isEmpty() and
531543
exists(result)

0 commit comments

Comments
 (0)