sebasjm / checker-framework

Automatically exported from code.google.com/p/checker-framework
Other
0 stars 1 forks source link

Error messages should be consistent with javac's #100

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Each type-checking error message that is yielded by the Checker Framework
should be consistent with the corresponding error message yielded by the
regular compiler.

Here is one example of inconsistency:

This code:

public class TestGenerics {
  class F<T extends Double> { }
  class G extends F<Integer> { }
}

yields this compilation error message:

% javac -g TestGenerics.java
TestGenerics.java:3: error: type argument Integer is not within bounds of 
type-variable T
  class G extends F<Integer> { }
                    ^
  where T is a type-variable:
    T extends Double declared in class TestGenerics.F

but this code:

import checkers.nullness.quals.*;
public class TestGenericsQualifier {
  class F<T extends Object> { }
  class G extends F<@Nullable Integer> { }
}

yields this much less useful compilation error message, which is misleading
in terms of the requirement and inconsistent with the similar message
issued by the regular compiler.

% javac -processor checkers.nullness.NullnessChecker -g 
TestGenericsQualifier.java
TestGenericsQualifier.java:4: error: invalid type argument;
  class G extends F<@Nullable Integer> { }
                                     ^
  found   : @Nullable Integer
  required: @NonNull Object

Original issue reported on code.google.com by michael.ernst@gmail.com on 1 Jul 2011 at 4:01

GoogleCodeExporter commented 9 years ago
Here are the two code snippets, as files that can be compiled using the command 
lines in the above bug report.

Original comment by michael.ernst@gmail.com on 1 Jul 2011 at 4:02

Attachments:

GoogleCodeExporter commented 9 years ago
The output is changed, but still isn't as specific as javac.  The current 
output is:

% javac -processor checkers.nullness.NullnessChecker -g 
TestGenericsQualifier.java
TestGenericsQualifier.java:4: error: incompatible types in type argument.
  class G extends F<@Nullable Integer> { }
                    ^
  found   : @NonRaw @Nullable Integer
  required: @NonNull @NonRaw Object
1 error

It would still be good to make the error message more like javac's, both for 
uniformity and because javac's is more informative; both will lead to less 
confusion among users.

Original comment by michael.ernst@gmail.com on 28 Mar 2013 at 6:19