Skip to content

Commit b365ff0

Browse files
committed
Ruby: Fix SynthSplatParameterElementNode
Make this class into a proper subclass of `ParameterNodeImpl`, to prevent some consistency test failures.
1 parent 5fff9fa commit b365ff0

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -885,19 +885,25 @@ private module ParameterNodes {
885885
* A node that holds the content of a specific positional argument.
886886
* See `SynthSplatArgumentNode` for more information.
887887
*/
888-
class SynthSplatParameterElementNode extends TSynthSplatParameterElementNode {
888+
class SynthSplatParameterElementNode extends ParameterNodeImpl, TSynthSplatParameterElementNode {
889889
private DataFlowCallable callable;
890890
private int pos;
891891

892892
SynthSplatParameterElementNode() { this = TSynthSplatParameterElementNode(callable, pos) }
893893

894894
int getPosition() { result = pos }
895895

896-
DataFlowCallable getCallable() { result = callable }
896+
final override Parameter getParameter() { none() }
897+
898+
final override predicate isParameterOf(DataFlowCallable c, ParameterPosition p) { none() }
899+
900+
final override CfgScope getCfgScope() { result = callable.asCallable() }
897901

898-
string toString() { result = "synthetic *args[" + pos + "]" }
902+
final override DataFlowCallable getEnclosingCallable() { result = callable }
903+
904+
final override Location getLocationImpl() { result = callable.getLocation() }
899905

900-
Location getLocation() { result = callable.getLocation() }
906+
final override string toStringImpl() { result = "synthetic *args[" + pos + "]" }
901907
}
902908

903909
/** A parameter for a library callable with a flow summary. */
@@ -1344,7 +1350,9 @@ predicate storeStepCommon(Node node1, ContentSet c, Node node2) {
13441350
exists(SynthSplatParameterElementNode elemNode, NormalParameterNode splatNode, int splatPos |
13451351
elemNode = node1 and splatNode = node2
13461352
|
1347-
splatNode.isParameterOf(elemNode.getCallable(), any(ParameterPosition p | p.isSplat(splatPos))) and
1353+
splatNode
1354+
.isParameterOf(elemNode.getEnclosingCallable(),
1355+
any(ParameterPosition p | p.isSplat(splatPos))) and
13481356
c = getPositionalContent(elemNode.getPosition() - splatPos)
13491357
)
13501358
}
@@ -1421,7 +1429,7 @@ predicate readStep(Node node1, ContentSet c, Node node2) {
14211429
exists(SynthSplatArgParameterNode fromNode, SynthSplatParameterElementNode toNode, int pos |
14221430
node1 = fromNode and node2 = toNode
14231431
|
1424-
fromNode.isParameterOf(toNode.getCallable(), _) and
1432+
fromNode.isParameterOf(toNode.getEnclosingCallable(), _) and
14251433
c = getPositionalContent(pos) and
14261434
toNode.getPosition() = pos
14271435
)

0 commit comments

Comments
 (0)