Java: Fix false positives in evaluation-to-constant query for ErrorType#20546
Merged
Java: Fix false positives in evaluation-to-constant query for ErrorType#20546
Conversation
d66fbde to
b82d8c2
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
Fixes false positives in the evaluation-to-constant query for ErrorType by adding a type check to exclude TypeAccess expressions that resolve to ErrorType. This prevents the query from incorrectly flagging unresolved types as constant expressions.
- Added type check condition to exclude ErrorType instances from constant expression evaluation
- Added integration test to verify the fix works correctly for unresolved types like
Minecraft
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
ConstantExpAppearsNonConstant.ql |
Modified predicate to exclude TypeAccess expressions that resolve to ErrorType |
test.py |
Created integration test configuration |
Test.java |
Added test case with unresolved Minecraft type reference |
ConstantExpAppearsNonConstant.qlref |
Added query reference for integration test |
owen-mc
previously approved these changes
Sep 30, 2025
.../integration-tests/java/evaluation-to-constant-errortype/ConstantExpAppearsNonConstant.qlref
Outdated
Show resolved
Hide resolved
java/ql/src/Likely Bugs/Arithmetic/ConstantExpAppearsNonConstant.ql
Outdated
Show resolved
Hide resolved
owen-mc
approved these changes
Sep 30, 2025
Contributor
|
Late to the party, but I see that there are a ton of new results now besides of course a lot of removed results. Are these new TPs? |
Contributor
|
Just checked some - these definitely look like a ton of new FPs, so that's quite unfortunate. I'll put up a PR with a fix. |
Contributor
|
Fix here: #20600 |
Contributor
Author
|
Thanks for the fix @aschackmull! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes the FPs described in the issue linked below.
Closes: http://github.com/github/codeql-java-team/issues/425
DCA Nightly Buildless: https://github.com/github/codeql-dca-main/issues/31838
DCA Nightly: https://github.com/github/codeql-dca-main/issues/31839