rescript-lang / rescript-lang/rescript

[reanalyze] [bug] nested functions trigger @raises annotation

Open
#7,677 0 comments 0 reactions 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:

exception MyException
let foo = () => {
  @raises(MyException)
  let bar = () => {
    throw(MyException)
  }
  {"bar": bar}
}

it's trivial to see above that foo can never raise MyException. despite this, reanalyze exception analysis suggests that foo should be annotated:

{
  "name": "Exception Analysis",
  "kind": "warning",
  "file": "Foo.res",
  "range": [21,4,21,7],
  "message": "foo might raise MyException (Foo.res:27:10) and is not annotated with @raises(MyException)",
  "annotate": { "line": 21, "character": 0, "text": "@raises(MyException)\n", "action": "Add @raises annotation"}
}

this is incorrect and the annotation should not be suggested.

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 nested-function example in Foo.res with reanalyze's Exception Analysis. Trace why the inner bar annotation is attributed to foo; done means the analyzer no longer suggests @raises(MyException) for foo while preserving the annotation for bar.

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
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.