Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaExpression parser reports incorrect types #6939

Open
JohnnyJayJay opened this issue Dec 26, 2024 · 2 comments · May be fixed by #6940
Open

JavaExpression parser reports incorrect types #6939

JohnnyJayJay opened this issue Dec 26, 2024 · 2 comments · May be fixed by #6940
Labels

Comments

@JohnnyJayJay
Copy link

JohnnyJayJay commented Dec 26, 2024

I'm using JavaExpression to represent simple expressions. I've noticed BinaryOperations get assigned the wrong return type for comparison operators.

For example, evaluating the expression StringToJavaExpression.atPath("6 > 5", getCurrentPath(), checker).getType() in a BaseTypeVisitor yields a primitive TypeMirror for int, when it should be boolean. The same is true for other comparison operators: <, <=, >=, ==, !=. All of them supposedly produce an int instead of a boolean. It's analogous for comparisons involving other primitive types.

I'm running this with JDK 21, Checker Framework version 3.48.3.

I believe I've identified the issue to be located here. The handling for binary expressions falsely assumes that the return type of the expression is always directly related to the type of the operands.

@mernst mernst linked a pull request Dec 26, 2024 that will close this issue
@mernst
Copy link
Member

mernst commented Dec 26, 2024

Thanks for the report and especially for the pull request. (And our apologies for the bug.)

@mernst mernst added the bug label Dec 26, 2024
@JohnnyJayJay
Copy link
Author

Thanks for the report and especially for the pull request. (And our apologies for the bug.)

No need for any apologies, thanks for getting back to me so quickly. I'll get to the PR soon. I hope you've had/you're having a relaxing holiday season 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants