rescript-association/reanalyze

Catching on exception from other module leads to incorrect warning

fhammerschmidt opened this issue · 3 comments

Consider the following example:

module Test = {
  exception Nested

  @raises(Nested)
  let raises = async () => raise(Nested)
}

let raises = async () =>
  try await Test.raises() catch {
  | Test.Nested => Js.log("Not found")
  }

it gives me:
raises might raise Nested (test.res:9:12) and is not annotated with @raises(Nested)

However, if I open Test instead:

module Test = {
  exception Nested

  @raises(Nested)
  let raises = async () => raise(Nested)
}

open Test

let raises = async () =>
  try await Test.raises() catch {
  | Nested => Js.log("Not found")
  }

Everything works fine

The exception analysis has a simple model for exception paths, which are taken literally.
It does not try to resolve scope or aliasing.

Btw the analysis is now integrated in the editor extension, so this could be moved there.

Ok, closing this in favor of rescript-lang/rescript-vscode#716