You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import org.checkerframework.common.value.qual.*;
class A {
@IntRange(from = 5, to = 10) int a;
void foo1() {
if (a == 5) {
a += 5;
}
}
void foo2(@IntRange(from = 5, to = 10) int b) {
if (b == 5) {
b += 5;
}
}
}
I expect the constant value checker to produce no errors, but it generates the following error messages:
error: [compound.assignment.type.incompatible] expression type incompatible with left-hand side in compound assignment.
a += 5;
^
found : @UnknownVal int
required: @IntRange(from=5, to=10) int
error: [compound.assignment.type.incompatible] expression type incompatible with left-hand side in compound assignment.
b += 5;
^
found : @UnknownVal int
required: @IntRange(from=5, to=10) int
As shown above, this issue happens to fields and method parameters. But if a was a local variable declared in the method body, then the checker will work as expected.
The text was updated successfully, but these errors were encountered:
zcai1
changed the title
Value Checker Reports @UnknownVal for Compound Assignment on Non-local Variables
Value Checker Reports @UnknownVal for Compound Assignment on Some Variables
Oct 27, 2021
Example:
I expect the constant value checker to produce no errors, but it generates the following error messages:
As shown above, this issue happens to fields and method parameters. But if
a
was a local variable declared in the method body, then the checker will work as expected.When
a
is a field, the corresponding CFG node is:When
b
is a method parameter, the corresponding CFG node is:When
a
is a local variable declared in the method body, the corresponding CFG node is:Observe that the type changes after "TypeCast".
The text was updated successfully, but these errors were encountered: