Skip to content

Commit 0f1b348

Browse files
committed
Ruby: Use another join order for nested constant lookup
1 parent a195ea9 commit 0f1b348

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

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

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,8 +1106,8 @@ private newtype TConstLookupScope =
11061106
MkQualifiedLookup(ConstantAccess base) or
11071107
/** Look up in the ancestors of `mod`. */
11081108
MkAncestorLookup(Module mod) or
1109-
/** Look up in a module syntactically nested in `scope`. */
1110-
MkNestedLookup(ModuleBase scope) or
1109+
/** Look up in a module syntactically nested in a declaration of `mod`. */
1110+
MkNestedLookup(Module mod) or
11111111
/** Pseudo-scope for accesses that are known to resolve to `mod`. */
11121112
MkExactLookup(Module mod)
11131113

@@ -1178,15 +1178,6 @@ class ConstRef extends LocalSourceNode {
11781178
*/
11791179
private ModuleNode getAncestryTarget() { result.getAnAncestorExpr() = this }
11801180

1181-
/**
1182-
* Gets a module scope in which the value of this constant is part of `Module.nesting`.
1183-
*/
1184-
private ModuleBase getANestingScope() {
1185-
result = this.getAncestryTarget().getADeclaration()
1186-
or
1187-
result.getEnclosingModule() = this.getANestingScope()
1188-
}
1189-
11901181
/**
11911182
* Gets the known target module.
11921183
*
@@ -1204,7 +1195,7 @@ class ConstRef extends LocalSourceNode {
12041195
access = any(ConstantAccess ac).getScopeExpr() and
12051196
result = MkQualifiedLookup(access)
12061197
or
1207-
result = MkNestedLookup(this.getANestingScope())
1198+
result = MkNestedLookup(this.getAncestryTarget())
12081199
or
12091200
result = MkExactLookup(access.(Namespace).getModule())
12101201
}
@@ -1224,7 +1215,7 @@ class ConstRef extends LocalSourceNode {
12241215
(
12251216
result = MkAncestorLookup(access.getEnclosingModule().getNamespaceOrToplevel().getModule())
12261217
or
1227-
result = MkNestedLookup(access.getEnclosingModule())
1218+
result = MkNestedLookup(access.getEnclosingModule().getEnclosingModule*().getModule())
12281219
)
12291220
}
12301221

0 commit comments

Comments
 (0)