Skip to content

Commit fa8cbee

Browse files
authored
Merge pull request #20546 from github/idrissrio/ql-constant
Java: Fix false positives in evaluation-to-constant query for ErrorType
2 parents 90a7a58 + 6377111 commit fa8cbee

File tree

5 files changed

+12
-1
lines changed

5 files changed

+12
-1
lines changed

java/ql/integration-tests/java/evaluation-to-constant-errortype/ConstantExpAppearsNonConstant.expected

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
query: Likely Bugs/Arithmetic/ConstantExpAppearsNonConstant.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Test {
2+
public static void updateFlashlights(Minecraft mc){
3+
if(mc.world != null){
4+
5+
}
6+
}
7+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def test(codeql, java):
2+
codeql.database.create(build_mode="none")

java/ql/src/Likely Bugs/Arithmetic/ConstantExpAppearsNonConstant.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ predicate isConstantExp(Expr e) {
1919
// A literal is constant.
2020
e instanceof Literal
2121
or
22-
e instanceof TypeAccess
22+
e instanceof TypeAccess and not e.(TypeAccess).getType() instanceof ErrorType
2323
or
2424
e instanceof ArrayTypeAccess
2525
or

0 commit comments

Comments
 (0)