rescript-lang / rescript-lang/rescript
[reanalyze] [bug] division_by_zero exception analysis should check constant denominators
Open
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 7.5k
- Forks
- 485
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 55
Description
repro:
let foo = (x: int) => {
x / 10
}
reanalyze gives:
{
"name": "Exception Analysis",
"kind": "warning",
"file": "Foo.res",
"range": [20,4,20,7],
"message": "foo might raise Division_by_zero (Foo.res:22:4) and is not annotated with @raises(Division_by_zero)",
"annotate": { "line": 20, "character": 0, "text": "@raises(Division_by_zero)\n", "action": "Add @raises annotation"}
}
it's trivially clear that division by zero can't happen, and so reanalyze should not suggest the annotation.
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.
Research direction
Start in the reanalyze exception-analysis path that reports Division_by_zero for the shown x / 10 expression. Trace how denominator values are classified, then verify that a constant nonzero denominator no longer produces the annotation warning while the issue's reproduction remains covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100