Merge pull request #20546 from github/idrissrio/ql-constant

Java: Fix false positives in evaluation-to-constant query for ErrorType
This commit is contained in:
Idriss Riouak
2025-09-30 14:24:28 +02:00
committed by GitHub
5 changed files with 12 additions and 1 deletions

View File

@@ -0,0 +1,2 @@
query: Likely Bugs/Arithmetic/ConstantExpAppearsNonConstant.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -0,0 +1,7 @@
class Test {
public static void updateFlashlights(Minecraft mc){
if(mc.world != null){
}
}
}

View File

@@ -0,0 +1,2 @@
def test(codeql, java):
codeql.database.create(build_mode="none")

View File

@@ -19,7 +19,7 @@ predicate isConstantExp(Expr e) {
// A literal is constant.
e instanceof Literal
or
e instanceof TypeAccess
e instanceof TypeAccess and not e.(TypeAccess).getType() instanceof ErrorType
or
e instanceof ArrayTypeAccess
or