typetools / typetools/checker-framework
Unclear error message in enums
@wmdietl is already working on this.
Since Nov 18, 2019.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
In enumerations, the enum elements are implicitly assigned, leading to an unintuitive error. Consider this enum,
import org.checkerframework.checker.tainting.qual.*;
public enum C {
@Untainted A
}
When I run javac -processor TaintingChecker C.java I get the error,
C.java:4: error: [assignment.type.incompatible] incompatible types in assignment.
@Untainted A
^
found : @Tainted C
required: @Untainted C
The error is that A is actually a field which is assigned to a default constructed instance of C, which is Tainted. However, there's no explicit assignment in the code so without knowledge of how Java implements enums this error is confusing.
When enum fields are set to invalid values, it should be clear that it's because they're implicitly being assigned to a newly constructed value. Perhaps add a different error name for invalid assignments in enums.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.