typetools / typetools/checker-framework

Improvement of error message in [type.invalid.conflicting.annos] error

Open
#2,396 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue
Dominant language
Java
Stars
1.1k
Forks
440
Avg merge
1d 12h
Merged PRs (30d)
134

Description

Consider the following code:

import org.checkerframework.common.value.qual.*;
import org.checkerframework.checker.index.qual.*;

class ltlength{
    public void check(int[] data, `@IndexFor`("#1") `@LTLengthOf`(value = {"#1"}, offset = {"1"}) int offset){

    }
}

Run it by typing in the terminal:
javac -processor org.checkerframework.checker.index.IndexChecker ltlength.java

Output:

ltlength.java:5: error: [type.invalid.conflicting.annos] invalid type: conflicting annotations [`@LTLengthOf`(value="data", offset="1"), `@LTLengthOf`(value="data", offset={})] in type "`@LTLengthOf`(value="data", offset="1") `@LTLengthOf`(value="data", offset={}) int"
    public void check(int[] data, `@IndexFor`("#1") `@LTLengthOf`(value = {"#1"}, offset = {"1"}) int offset){

This error is produced because @IndexFor("#1") is implemented as @LTLengthOf("#1") which conflicts with the second annotation @LTLengthOf(value = {"#1"}, offset = {"1"}).
But, in the error message, there is no mention of @IndexFor("#1") being compared as @LTLengthOf("#1") which may confuse the programmer as to why this error is being produced.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the example with javac -processor org.checkerframework.checker.index.IndexChecker ltlength.java and inspect the diagnostic identified as type.invalid.conflicting.annos. Trace how @IndexFor("#1") is represented as @LTLengthOf("#1"); done means the error message makes that comparison clear while preserving the conflicting-annotation details.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.