typetools / typetools/checker-framework

Correct location and format of flow expression parse errors

Open
#1,129 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Take this example:

import org.checkerframework.checker.nullness.qual.*;

class ExpressionParse {
  @RequiresNonNull("kdfj")
  @EnsuresNonNull("skdfj")
  void bar() {}
}

Running the Nullness Checker gives:

ExpressionParse.java:6: error: [flowexpr.parse.error] cannot parse the expression 'kdfj: identifier not found'
  void bar() {}
       ^
ExpressionParse.java:6: error: [flowexpr.parse.error] cannot parse the expression 'kdfj: identifier not found'
  void bar() {}
       ^
ExpressionParse.java:6: error: [flowexpr.parse.error] cannot parse the expression 'skdfj: identifier not found'
  void bar() {}
       ^
3 errors

(The duplicate pre-condition error is being tracked as https://github.com/typetools/checker-framework/issues/1051)

Some possible improvements:

  • It would be useful if the error message were on the line where the invalid String is and not always on the method declaration.
  • It might also be useful to output more context, e.g. within which annotation the expression was.
  • The message is rather confusingly presented: the code didn't try to parse skdfj: identifier not found; it tried to parse skdfj and that failed because that identifier wasn't found.

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 the Nullness Checker and the @RequiresNonNull and @EnsuresNonNull annotations shown in ExpressionParse.java. Trace how the flow expression parse error is reported, then define completion as reporting the error at the invalid String, including useful annotation context, and presenting the failed expression and cause clearly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
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.