rescript-lang / rescript-lang/rescript

[reanalyze] [bug] division_by_zero exception analysis should check constant denominators

Open
#7,679 0 comments 1 reaction 0 assignees View on GitHub

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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.