Skip to content

Commit 65835cd

Browse files
authored
Merge pull request github#12907 from hvitved/ruby/destructured-assign-join
Ruby: Fix bad join in `DestructuredAssignDesugar`
2 parents b47c8e8 + 71cd973 commit 65835cd

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

ruby/ql/lib/codeql/ruby/ast/internal/Synthesis.qll

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,8 @@ private module DestructuredAssignDesugar {
952952
}
953953

954954
abstract private class LhsWithReceiver extends Expr {
955+
LhsWithReceiver() { this = any(DestructuredAssignExpr dae).getElement(_) }
956+
955957
abstract Expr getReceiver();
956958

957959
abstract SynthKind getSynthKind();
@@ -960,8 +962,14 @@ private module DestructuredAssignDesugar {
960962
private class LhsCall extends LhsWithReceiver instanceof MethodCall {
961963
final override Expr getReceiver() { result = MethodCall.super.getReceiver() }
962964

965+
pragma[nomagic]
966+
private string getMethodName(int args) {
967+
result = super.getMethodName() and
968+
args = super.getNumberOfArguments()
969+
}
970+
963971
final override SynthKind getSynthKind() {
964-
result = MethodCallKind(super.getMethodName(), false, super.getNumberOfArguments())
972+
exists(int args | result = MethodCallKind(this.getMethodName(args), false, args))
965973
}
966974
}
967975

@@ -1154,9 +1162,7 @@ private module DestructuredAssignDesugar {
11541162
)
11551163
}
11561164

1157-
final override predicate excludeFromControlFlowTree(AstNode n) {
1158-
n = any(DestructuredAssignExpr tae).getElement(_).(LhsWithReceiver)
1159-
}
1165+
final override predicate excludeFromControlFlowTree(AstNode n) { n instanceof LhsWithReceiver }
11601166
}
11611167
}
11621168

0 commit comments

Comments
 (0)