rescript-lang / rescript-lang/rescript
[reanalyze] [bug] nested functions trigger @raises annotation
Open
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
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 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