typetools / typetools/checker-framework

charAt LowerBound Unknown

Open
#3,195 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

charAt should return a non-negative char. Consider the following test case:

class CharAtTest {
    @NonNegative char test1(@MinLen(1) String s) {
        return s.charAt(0);
    }
}

Output:

CharAtTest.java:6: error: [return.type.incompatible] incompatible types in return.
        return s.charAt(0);
                       ^
  type of expression: @LowerBoundUnknown char
  method return type: @NonNegative char
1 error

Expected: No errors
I'll be working on fixing this issue.

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 CharAtTest example using String.charAt(0) with the @NonNegative return type. Investigate the checker behavior that assigns @LowerBoundUnknown to charAt, then verify that the example compiles without errors and preserves the expected non-negative typing.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.