From a12807e4436b9fa1d9f5edad1940c3afaaa3bd6e Mon Sep 17 00:00:00 2001 From: tsnobip Date: Wed, 4 Jun 2025 13:47:09 +0200 Subject: [PATCH] sync Reanalyze with the new API around exception --- CHANGELOG.md | 1 + analysis/reanalyze/src/ExnLib.ml | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86fab3a77e..5952aa7fee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ - In module declarations, accept the invalid syntax `M = {...}` and format it to `M : {...}`. https://github.com/rescript-lang/rescript/pull/7527 - Improve doc comment formatting to match the style of multiline comments. https://github.com/rescript-lang/rescript/pull/7529 - Improve error messages around type mismatches for try/catch, if, for, while, and optional record fields + optional function arguments. https://github.com/rescript-lang/rescript/pull/7522 +- sync Reanalyze with the new APIs around exception. https://github.com/rescript-lang/rescript/pull/7536 #### :house: Internal diff --git a/analysis/reanalyze/src/ExnLib.ml b/analysis/reanalyze/src/ExnLib.ml index 705f38a125..0903b54e0e 100644 --- a/analysis/reanalyze/src/ExnLib.ml +++ b/analysis/reanalyze/src/ExnLib.ml @@ -63,7 +63,22 @@ let raisesLibTable : (Name.t, Exceptions.t) Hashtbl.t = ("fromStringOrThrow", [invalidArgument]); ] in - let stdlibError = [("raise", [jsExn])] in + let stdlibJsError = + [ + ("EvalError.throwWithMessage", [jsExn]); + ("RangeError.throwWithMessage", [jsExn]); + ("ReferenceError.throwWithMessage", [jsExn]); + ("SyntaxError.throwWithMessage", [jsExn]); + ("TypeError.throwWithMessage", [jsExn]); + ("URIError.throwWithMessage", [jsExn]); + ("panic", [jsExn]); + ("throw", [jsExn]); + ("throwWithMessage", [jsExn]); + ] + in + let stdlibError = + [("raise", [jsExn]); ("panic", [jsExn]); ("throw", [jsExn])] + in let stdlibExn = [ ("raiseError", [jsExn]); @@ -156,6 +171,7 @@ let raisesLibTable : (Name.t, Exceptions.t) Hashtbl.t = ("Bool", stdlibBool); ("Error", stdlibError); ("Exn", stdlibExn); + ("JsError", stdlibJsError); ("Js.Json", [("parseExn", [jsExn])]); ("JSON", stdlibJson); ("Json_decode", bsJson); @@ -178,6 +194,8 @@ let raisesLibTable : (Name.t, Exceptions.t) Hashtbl.t = ("Stdlib.Error", stdlibError); ("Stdlib_Exn", stdlibExn); ("Stdlib.Exn", stdlibExn); + ("Stdlib_JsError", stdlibJsError); + ("Stdlib.JsError", stdlibJsError); ("Stdlib_JSON", stdlibJson); ("Stdlib.JSON", stdlibJson); ("Stdlib_List", stdlibList);