Skip to content

Commit 6ebaff3

Browse files
committed
Python: Fix broken queries
1 parent 09e1f8d commit 6ebaff3

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

python/ql/lib/analysis/DefinitionTracking.qll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,10 @@ Definition getUniqueDefinition(Expr use) {
471471
not result = TLocalDefinition(use)
472472
}
473473

474-
/** A helper class to get suitable locations for attributes */
475-
class NiceLocationExpr extends Expr {
476-
/** Gets a textual representation of this element. */
477-
override string toString() { result = this.(Expr).toString() }
474+
final class FinalExpr = Expr;
478475

476+
/** A helper class to get suitable locations for attributes */
477+
class NiceLocationExpr extends FinalExpr {
479478
/**
480479
* Holds if this element is at the specified location.
481480
* The location spans column `bc` of line `bl` to

python/ql/src/Variables/LoopVariableCapture/LoopVariableCaptureQuery.qll

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import python
44
import semmle.python.dataflow.new.DataFlow
55

6+
final class FinalAstNode = AstNode;
7+
68
/** A looping construct. */
7-
abstract class Loop extends AstNode {
9+
abstract class Loop extends FinalAstNode {
810
/**
911
* Gets a loop variable of this loop.
1012
* For example, `x` and `y` in `for x,y in pairs: print(x+y)`
@@ -13,9 +15,9 @@ abstract class Loop extends AstNode {
1315
}
1416

1517
/** A `for` loop. */
16-
private class ForLoop extends Loop, For {
18+
private class ForLoop extends Loop instanceof For {
1719
override Variable getALoopVariable() {
18-
this.getTarget() = result.getAnAccess().getParentNode*() and
20+
this.(For).getTarget() = result.getAnAccess().getParentNode*() and
1921
result.getScope() = this.getScope()
2022
}
2123
}

python/ql/src/analysis/ImportFailure.ql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ predicate ok_to_fail(ImportExpr ie) {
5959
os_specific_import(ie) != get_os()
6060
}
6161

62-
class VersionTest extends ControlFlowNode {
62+
final class FinalControlFlowNode = ControlFlowNode;
63+
64+
class VersionTest extends FinalControlFlowNode {
6365
VersionTest() {
6466
exists(string name |
6567
name.matches("%version%") and
@@ -70,7 +72,7 @@ class VersionTest extends ControlFlowNode {
7072
)
7173
}
7274

73-
override string toString() { result = "VersionTest" }
75+
string toString() { result = "VersionTest" }
7476
}
7577

7678
/** A guard on the version of the Python interpreter */

0 commit comments

Comments
 (0)