From f86a868d3c6a2bf79a378a4d9f7d654bd26792bc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Oct 2025 09:29:23 +0000 Subject: [PATCH 01/10] Initial plan From e6baddc0b762c2ff0d407430e6b54ecbf2177ce3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Oct 2025 09:42:08 +0000 Subject: [PATCH 02/10] Deprecate @raises in favor of @throws in reanalyze - Update reanalyze Exception.ml to accept both @throws and @raises decorators - Update warning messages to use @throws terminology - Add @throws decorator to completion with documentation - Mark @raises as deprecated in completion - Update all test files to use @throws instead of @raises - Update expected test outputs to reflect @throws terminology - Update Stdlib_JSON to use @throws instead of @raises Co-authored-by: tsnobip <2479216+tsnobip@users.noreply.github.com> --- analysis/reanalyze/src/Exception.ml | 5 +- analysis/reanalyze/src/Log_.ml | 6 +-- analysis/src/CompletionDecorators.ml | 13 +++++- packages/@rescript/runtime/Stdlib_JSON.res | 18 ++++---- packages/@rescript/runtime/Stdlib_JSON.resi | 18 ++++---- .../deadcode/expected/exception.txt | 46 +++++++++---------- .../deadcode/src/exception/BeltTest.res | 20 ++++---- .../deadcode/src/exception/Exn.res | 18 ++++---- .../deadcode/src/exception/ExnB.res | 2 +- .../deadcode/src/exception/ExternalTest.res | 4 +- .../deadcode/src/exception/StdlibTest.res | 10 ++-- .../deadcode/src/exception/TestYojson.res | 6 +-- .../deadcode/src/exception/Yojson.res | 4 +- tests/syntax_benchmarks/data/Napkinscript.res | 2 +- 14 files changed, 92 insertions(+), 80 deletions(-) diff --git a/analysis/reanalyze/src/Exception.ml b/analysis/reanalyze/src/Exception.ml index d59516e2dd..afc1ba3bbc 100644 --- a/analysis/reanalyze/src/Exception.ml +++ b/analysis/reanalyze/src/Exception.ml @@ -211,7 +211,7 @@ module Checks = struct raiseSet in Format.asprintf - "@{%s@} %a and is annotated with redundant @raises(%a)" + "@{%s@} %a and is annotated with redundant @throws(%a)" exnName raisesDescription () (Exceptions.pp ~exnTable:None) redundantAnnotations); @@ -362,7 +362,8 @@ let traverseAst () = let getExceptionsFromAnnotations attributes = let raisesAnnotationPayload = attributes - |> Annotation.getAttributePayload (fun s -> s = "raises" || s = "raise") + |> Annotation.getAttributePayload (fun s -> + s = "throws" || s = "throw" || s = "raises" || s = "raise") in let rec getExceptions payload = match payload with diff --git a/analysis/reanalyze/src/Log_.ml b/analysis/reanalyze/src/Log_.ml index 2bb6aa0e9e..744ace0ae4 100644 --- a/analysis/reanalyze/src/Log_.ml +++ b/analysis/reanalyze/src/Log_.ml @@ -102,9 +102,9 @@ let missingRaiseInfoToText {missingAnnotations; locFull} = Format.asprintf "%a" (Exceptions.pp ~exnTable:None) missingAnnotations in if !Cli.json then - EmitJson.emitAnnotate ~action:"Add @raises annotation" + EmitJson.emitAnnotate ~action:"Add @throws annotation" ~pos:(EmitJson.locToPos locFull) - ~text:(Format.asprintf "@raises(%s)\\n" missingTxt) + ~text:(Format.asprintf "@throws(%s)\\n" missingTxt) else "" let logAdditionalInfo ~(description : description) = @@ -126,7 +126,7 @@ let missingRaiseInfoToMessage {exnTable; exnName; missingAnnotations; raiseSet} Format.asprintf "%a" (Exceptions.pp ~exnTable:None) missingAnnotations in Format.asprintf - "@{%s@} might raise %s and is not annotated with @raises(%s)" exnName + "@{%s@} might raise %s and is not annotated with @throws(%s)" exnName raisesTxt missingTxt let descriptionToMessage (description : description) = diff --git a/analysis/src/CompletionDecorators.ml b/analysis/src/CompletionDecorators.ml index ffe18ed7d8..a594a2469f 100644 --- a/analysis/src/CompletionDecorators.ml +++ b/analysis/src/CompletionDecorators.ml @@ -149,12 +149,23 @@ The `@new` decorator is used whenever you need to bind to a JavaScript class con ( "raises", Some "raises(\"$0\")", [ - {|The `@raises` decorator is for reanalyze, a static analysis tool for ReScript that can perform exception analysis. + {|The `@raises` decorator is deprecated. Please use `@throws` instead. `@raises` acknowledges that a function can raise exceptions that are not caught, and suppresses a warning in that case. Callers of the functions are then subjected to the same rule. Example `@raises(Exn)` or `@raises([E1, E2, E3])` for multiple exceptions. [Read more and see examples in the documentation](https://github.com/rescript-association/reanalyze/blob/master/EXCEPTION.md). +> Hint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!|}; + ] ); + ( "throws", + Some "throws(\"$0\")", + [ + {|The `@throws` decorator is for reanalyze, a static analysis tool for ReScript that can perform exception analysis. + +`@throws` acknowledges that a function can raise exceptions that are not caught, and suppresses +a warning in that case. Callers of the functions are then subjected to the same rule. +Example `@throws(Exn)` or `@throws([E1, E2, E3])` for multiple exceptions. +[Read more and see examples in the documentation](https://github.com/rescript-association/reanalyze/blob/master/EXCEPTION.md). > Hint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!|}; ] ); ( "react.component", diff --git a/packages/@rescript/runtime/Stdlib_JSON.res b/packages/@rescript/runtime/Stdlib_JSON.res index 4535a5f7b3..b7fc9d21e3 100644 --- a/packages/@rescript/runtime/Stdlib_JSON.res +++ b/packages/@rescript/runtime/Stdlib_JSON.res @@ -10,12 +10,12 @@ type rec t = @unboxed type replacer = Keys(array) | Replacer((string, t) => t) -@raises @val external parseOrThrow: (string, ~reviver: (string, t) => t=?) => t = "JSON.parse" +@throws @val external parseOrThrow: (string, ~reviver: (string, t) => t=?) => t = "JSON.parse" -@deprecated("Use `parseOrThrow` instead") @raises @val +@deprecated("Use `parseOrThrow` instead") @throws @val external parseExn: (string, ~reviver: (string, t) => t=?) => t = "JSON.parse" -@deprecated("Use `parseOrThrow` with optional parameter instead") @raises @val +@deprecated("Use `parseOrThrow` with optional parameter instead") @throws @val external parseExnWithReviver: (string, (string, t) => t) => t = "JSON.parse" @val external stringify: (t, ~replacer: replacer=?, ~space: int=?) => string = "JSON.stringify" @@ -30,19 +30,19 @@ external stringifyWithFilter: (t, array) => string = "JSON.stringify" @deprecated("Use `stringify` with optional parameters instead") @val external stringifyWithFilterAndIndent: (t, array, int) => string = "JSON.stringify" -@raises @val +@throws @val external stringifyAny: ('a, ~replacer: replacer=?, ~space: int=?) => option = "JSON.stringify" -@deprecated("Use `stringifyAny` with optional parameter instead") @raises @val +@deprecated("Use `stringifyAny` with optional parameter instead") @throws @val external stringifyAnyWithIndent: ('a, @as(json`null`) _, int) => option = "JSON.stringify" -@deprecated("Use `stringifyAny` with optional parameter instead") @raises @val +@deprecated("Use `stringifyAny` with optional parameter instead") @throws @val external stringifyAnyWithReplacer: ('a, (string, t) => t) => option = "JSON.stringify" -@deprecated("Use `stringifyAny` with optional parameters instead") @raises @val +@deprecated("Use `stringifyAny` with optional parameters instead") @throws @val external stringifyAnyWithReplacerAndIndent: ('a, (string, t) => t, int) => option = "JSON.stringify" -@deprecated("Use `stringifyAny` with optional parameter instead") @raises @val +@deprecated("Use `stringifyAny` with optional parameter instead") @throws @val external stringifyAnyWithFilter: ('a, array) => string = "JSON.stringify" -@deprecated("Use `stringifyAny` with optional parameters instead") @raises @val +@deprecated("Use `stringifyAny` with optional parameters instead") @throws @val external stringifyAnyWithFilterAndIndent: ('a, array, int) => string = "JSON.stringify" module Classify = { diff --git a/packages/@rescript/runtime/Stdlib_JSON.resi b/packages/@rescript/runtime/Stdlib_JSON.resi index 6a6f6279c5..5133d4cac4 100644 --- a/packages/@rescript/runtime/Stdlib_JSON.resi +++ b/packages/@rescript/runtime/Stdlib_JSON.resi @@ -60,7 +60,7 @@ try { - Raises a SyntaxError (Exn.t) if the string isn't valid JSON. */ -@raises(Exn.t) @val +@throws(Exn.t) @val external parseOrThrow: (string, ~reviver: (string, t) => t=?) => t = "JSON.parse" /** @@ -106,7 +106,7 @@ try { - Raises a SyntaxError (Exn.t) if the string isn't valid JSON. */ -@deprecated("Use `parseOrThrow` instead") @raises(Exn.t) @val +@deprecated("Use `parseOrThrow` instead") @throws(Exn.t) @val external parseExn: (string, ~reviver: (string, t) => t=?) => t = "JSON.parse" /** @@ -142,7 +142,7 @@ try { - Raises a SyntaxError if the string is not a valid JSON. */ -@deprecated("Use `parseOrThrow` with optional parameter instead") @raises(Exn.t) @val +@deprecated("Use `parseOrThrow` with optional parameter instead") @throws(Exn.t) @val external parseExnWithReviver: (string, (string, t) => t) => t = "JSON.parse" /** @@ -399,7 +399,7 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { - Raises a TypeError if the value contains circular references. - Raises a TypeError if the value contains `BigInt`s. */ -@raises(Exn.t) @val +@throws(Exn.t) @val external stringifyAny: ('a, ~replacer: replacer=?, ~space: int=?) => option = "JSON.stringify" @@ -441,7 +441,7 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { - Raises a TypeError if the value contains circular references. - Raises a TypeError if the value contains `BigInt`s. */ -@deprecated("Use `stringifyAny` with optional parameter instead") @raises(Exn.t) @val +@deprecated("Use `stringifyAny` with optional parameter instead") @throws(Exn.t) @val external stringifyAnyWithIndent: ('a, @as(json`null`) _, int) => option = "JSON.stringify" /** @@ -487,7 +487,7 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { - Raises a TypeError if the value contains circular references. - Raises a TypeError if the value contains `BigInt`s. */ -@deprecated("Use `stringifyAny` with optional parameter instead") @raises @val +@deprecated("Use `stringifyAny` with optional parameter instead") @throws @val external stringifyAnyWithReplacer: ('a, (string, t) => t) => option = "JSON.stringify" /** @@ -534,7 +534,7 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { - Raises a TypeError if the value contains circular references. - Raises a TypeError if the value contains `BigInt`s. */ -@deprecated("Use `stringifyAny` with optional parameters instead") @raises @val +@deprecated("Use `stringifyAny` with optional parameters instead") @throws @val external stringifyAnyWithReplacerAndIndent: ('a, (string, t) => t, int) => option = "JSON.stringify" @@ -571,7 +571,7 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { - Raises a TypeError if the value contains circular references. - Raises a TypeError if the value contains `BigInt`s. */ -@deprecated("Use `stringifyAny` with optional parameter instead") @raises @val +@deprecated("Use `stringifyAny` with optional parameter instead") @throws @val external stringifyAnyWithFilter: ('a, array) => string = "JSON.stringify" /** @@ -621,7 +621,7 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { - Raises a TypeError if the value contains circular references. - Raises a TypeError if the value contains `BigInt`s. */ -@deprecated("Use `stringifyAny` with optional parameters instead") @raises @val +@deprecated("Use `stringifyAny` with optional parameters instead") @throws @val external stringifyAnyWithFilterAndIndent: ('a, array, int) => string = "JSON.stringify" module Classify: { diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/expected/exception.txt b/tests/analysis_tests/tests-reanalyze/deadcode/expected/exception.txt index 9bd59a72cc..97da30a746 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/expected/exception.txt +++ b/tests/analysis_tests/tests-reanalyze/deadcode/expected/exception.txt @@ -2,83 +2,83 @@ Exception Analysis Exn.res:1:5-10 - raises might raise Not_found (Exn.res:1:19) and is not annotated with @raises(Not_found) + raises might raise Not_found (Exn.res:1:19) and is not annotated with @throws(Not_found) Exception Analysis Exn.res:19:5-28 - callsRaiseWithAnnotation might raise Not_found (Exn.res:19:31) and is not annotated with @raises(Not_found) + callsRaiseWithAnnotation might raise Not_found (Exn.res:19:31) and is not annotated with @throws(Not_found) Exception Analysis Exn.res:22:5-42 - callsRaiseWithAnnotationAndIsAnnotated might raise Not_found (Exn.res:22:45) and is not annotated with @raises(Not_found) + callsRaiseWithAnnotationAndIsAnnotated might raise Not_found (Exn.res:22:45) and is not annotated with @throws(Not_found) Exception Analysis Exn.res:22:5-42 - callsRaiseWithAnnotationAndIsAnnotated might raise Not_found (Exn.res:22:45) and is annotated with redundant @raises(A) + callsRaiseWithAnnotationAndIsAnnotated might raise Not_found (Exn.res:22:45) and is annotated with redundant @throws(A) Exception Analysis Exn.res:24:5-19 - incompleteMatch might raise Match_failure (Exn.res:25:2) and is not annotated with @raises(Match_failure) + incompleteMatch might raise Match_failure (Exn.res:25:2) and is not annotated with @throws(Match_failure) Exception Analysis Exn.res:32:5-13 - twoRaises might raise [A (Exn.res:34:4), B (Exn.res:37:4)] and is not annotated with @raises([A, B]) + twoRaises might raise [A (Exn.res:34:4), B (Exn.res:37:4)] and is not annotated with @throws([A, B]) Exception Analysis Exn.res:41:5-14 - sequencing might raise A (Exn.res:42:2) and is not annotated with @raises(A) + sequencing might raise A (Exn.res:42:2) and is not annotated with @throws(A) Exception Analysis Exn.res:48:5-14 - wrongCatch might raise B (Exn.res:49:6) and is not annotated with @raises(B) + wrongCatch might raise B (Exn.res:49:6) and is not annotated with @throws(B) Exception Analysis Exn.res:54:5-15 - wrongCatch2 might raise [C (Exn.res:55:24), Match_failure (Exn.res:55:2)] and is not annotated with @raises([C, Match_failure]) + wrongCatch2 might raise [C (Exn.res:55:24), Match_failure (Exn.res:55:2)] and is not annotated with @throws([C, Match_failure]) Exception Analysis Exn.res:62:5-19 - raise2Annotate3 might raise [A (Exn.res:64:4), B (Exn.res:67:4)] and is annotated with redundant @raises(C) + raise2Annotate3 might raise [A (Exn.res:64:4), B (Exn.res:67:4)] and is annotated with redundant @throws(C) Exception Analysis Exn.res:73:5-24 - parse_json_from_file might raise Error (Exn.res:75:34) and is not annotated with @raises(Error) + parse_json_from_file might raise Error (Exn.res:75:34) and is not annotated with @throws(Error) Exception Analysis Exn.res:80:5-11 - reRaise might raise B (Exn.res:82:19) and is not annotated with @raises(B) + reRaise might raise B (Exn.res:82:19) and is not annotated with @throws(B) Exception Analysis Exn.res:91:5-22 - raiseInInternalLet might raise A (Exn.res:92:14) and is not annotated with @raises(A) + raiseInInternalLet might raise A (Exn.res:92:14) and is not annotated with @throws(A) Exception Analysis Exn.res:96:5-16 - indirectCall might raise Not_found (Exn.res:96:25) and is not annotated with @raises(Not_found) + indirectCall might raise Not_found (Exn.res:96:25) and is not annotated with @throws(Not_found) Exception Analysis Exn.res:121:5-16 - severalCases might raise Failure (Exn.res:123:13 Exn.res:124:13 Exn.res:125:15) and is not annotated with @raises(Failure) + severalCases might raise Failure (Exn.res:123:13 Exn.res:124:13 Exn.res:125:15) and is not annotated with @throws(Failure) Exception Analysis Exn.res:133:5-23 - redundantAnnotation raises nothing and is annotated with redundant @raises(Invalid_argument) + redundantAnnotation raises nothing and is annotated with redundant @throws(Invalid_argument) Exception Analysis Exn.res:135:5-6 - _x might raise A (Exn.res:135:9) and is not annotated with @raises(A) + _x might raise A (Exn.res:135:9) and is not annotated with @throws(A) Exception Analysis Exn.res:137:5 - _ might raise A (Exn.res:137:8) and is not annotated with @raises(A) + _ might raise A (Exn.res:137:8) and is not annotated with @throws(A) Exception Analysis Exn.res:139:5-6 - () might raise A (Exn.res:139:9) and is not annotated with @raises(A) + () might raise A (Exn.res:139:9) and is not annotated with @throws(A) Exception Analysis Exn.res:141:1-16 - Toplevel expression might raise Not_found (Exn.res:141:0) and is not annotated with @raises(Not_found) + Toplevel expression might raise Not_found (Exn.res:141:0) and is not annotated with @throws(Not_found) Exception Analysis Exn.res:151:46-47 @@ -86,14 +86,14 @@ Exception Analysis Exn.res:151:5-21 - onResultPipeWrong might raise Assert_failure (Exn.res:151:50) and is not annotated with @raises(Assert_failure) + onResultPipeWrong might raise Assert_failure (Exn.res:151:50) and is not annotated with @throws(Assert_failure) Exception Analysis ExnA.res:1:5-7 - bar might raise Not_found (ExnA.res:1:16) and is not annotated with @raises(Not_found) + bar might raise Not_found (ExnA.res:1:16) and is not annotated with @throws(Not_found) Exception Analysis ExternalTest.res:7:5-24 - bigIntFromStringExn2 might raise JsExn (ExternalTest.res:7:35) and is not annotated with @raises(JsExn) + bigIntFromStringExn2 might raise JsExn (ExternalTest.res:7:35) and is not annotated with @throws(JsExn) Analysis reported 24 issues (Exception Analysis:24) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/BeltTest.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/BeltTest.res index 4205f3e0b7..0a8910c486 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/BeltTest.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/BeltTest.res @@ -1,31 +1,31 @@ open Belt.List -@raises(Not_found) +@throws(Not_found) let lstHead1 = l => l->Belt.List.headExn -@raises(Not_found) +@throws(Not_found) let lstHead2 = l => l->Belt_List.headExn -@raises(Not_found) +@throws(Not_found) let mapGetExn1 = (s, k) => s->Belt.Map.Int.getExn(k) -@raises(Not_found) +@throws(Not_found) let mapGetExn2 = (s, k) => s->Belt_Map.Int.getExn(k) -@raises(Not_found) +@throws(Not_found) let mapGetExn3 = (s, k) => s->Belt_MapInt.getExn(k) -@raises(Not_found) +@throws(Not_found) let mapGetExn4 = (s, k) => s->Belt.Map.String.getExn(k) -@raises(Not_found) +@throws(Not_found) let mapGetExn5 = (s, k) => s->Belt_Map.String.getExn(k) -@raises(Not_found) +@throws(Not_found) let mapGetExn6 = (s, k) => s->Belt_MapString.getExn(k) -@raises(Not_found) +@throws(Not_found) let mapGetExn7 = (s, k) => s->Belt.Map.getExn(k) -@raises(Not_found) +@throws(Not_found) let mapGetExn8 = (s, k) => s->Belt_Map.getExn(k) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res index 89341b7fea..ed87e23ff9 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res @@ -13,12 +13,12 @@ let raiseAndCatch = try throw(Not_found) catch { | _ => () } -@raises(Not_found) +@throws(Not_found) let raisesWithAnnotaion = () => throw(Not_found) let callsRaiseWithAnnotation = raisesWithAnnotaion() -@raises(A) +@throws(A) let callsRaiseWithAnnotationAndIsAnnotated = raisesWithAnnotaion() let incompleteMatch = l => @@ -58,7 +58,7 @@ let wrongCatch2 = b => | list{} => () } -@raises([A, B, C]) +@throws([A, B, C]) let raise2Annotate3 = (x, y) => { if x { throw(A) @@ -106,16 +106,16 @@ let tryChar = v => { 42 } -@raises(Not_found) +@throws(Not_found) let raiseAtAt = () => \"@@"(raise, Not_found) -@raises(Not_found) +@throws(Not_found) let raisePipe = throw(Not_found) -@raises(Not_found) +@throws(Not_found) let raiseArrow = Not_found->raise -@raises(JsExn) +@throws(JsExn) let bar = () => Js.Json.parseExn("!!!") let severalCases = cases => @@ -126,10 +126,10 @@ let severalCases = cases => | _ => () } -@raises(genericException) +@throws(genericException) let genericRaiseIsNotSupported = exn => throw(exn) -@raises(Invalid_argument) +@throws(Invalid_argument) let redundantAnnotation = () => () let _x = throw(A) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/ExnB.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/ExnB.res index 3749dfd029..76a32a99e8 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/ExnB.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/ExnB.res @@ -1,2 +1,2 @@ -@raises(Not_found) +@throws(Not_found) let foo = () => throw(Not_found) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/ExternalTest.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/ExternalTest.res index acd09217a3..5964ca2ac4 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/ExternalTest.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/ExternalTest.res @@ -1,7 +1,7 @@ -@raises(JsExn) +@throws(JsExn) external bigIntFromStringExn: string => bigint = "BigInt" -@raises(JsExn) +@throws(JsExn) let bigIntFromStringExn = s => s->bigIntFromStringExn let bigIntFromStringExn2 = s => s->bigIntFromStringExn diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/StdlibTest.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/StdlibTest.res index 8a099f432e..79585f7db6 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/StdlibTest.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/StdlibTest.res @@ -1,14 +1,14 @@ -@raises(JsExn) +@throws(JsExn) let optionGetExn = o => o->Option.getExn -@raises(Not_found) +@throws(Not_found) let resultGetExn = r => r->Result.getExn -@raises(Invalid_argument) +@throws(Invalid_argument) let nullGetExn = n => n->Null.getExn -@raises(JsExn) +@throws(JsExn) let bigIntFromStringExn = s => s->BigInt.fromStringOrThrow -@raises(JsExn) +@throws(JsExn) let jsonParseExn = s => s->JSON.parseOrThrow diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/TestYojson.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/TestYojson.res index b98e4ff83f..6dda239e92 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/TestYojson.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/TestYojson.res @@ -1,4 +1,4 @@ -@raises(Yojson.Json_error) +@throws(Yojson.Json_error) let foo = x => Yojson.Basic.from_string(x) let bar = (str, json) => @@ -10,8 +10,8 @@ let bar = (str, json) => | exception Yojson.Basic.Util.Type_error("a", d) when d == json => json } -@raises(Yojson.Basic.Util.Type_error) +@throws(Yojson.Basic.Util.Type_error) let toString = x => Yojson.Basic.Util.to_string(x) -@raises(Yojson.Basic.Util.Type_error) +@throws(Yojson.Basic.Util.Type_error) let toInt = x => Yojson.Basic.Util.to_int(x) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Yojson.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Yojson.res index ec0f9c72f1..85dfbcc18e 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Yojson.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Yojson.res @@ -3,13 +3,13 @@ exception Json_error(string) module Basic = { type t - @raises(Json_error) + @throws(Json_error) let from_string: string => t = _ => throw(Json_error("Basic.from_string")) module Util = { exception Type_error(string, t) - @raises(Type_error) + @throws(Type_error) let member: (string, t) => t = (_s, j) => throw(Type_error("Basic.Util.member", j)) let to_int: t => int = _ => 34 diff --git a/tests/syntax_benchmarks/data/Napkinscript.res b/tests/syntax_benchmarks/data/Napkinscript.res index 2a026803e8..c09236f91d 100644 --- a/tests/syntax_benchmarks/data/Napkinscript.res +++ b/tests/syntax_benchmarks/data/Napkinscript.res @@ -1798,7 +1798,7 @@ module Token = { | Export => "export" } - @raises(Not_found) + @throws(Not_found) let keywordTable = x => switch x { | "true" => True From 8c82f5dc2090bb32223dd762b9c991be221a7d79 Mon Sep 17 00:00:00 2001 From: tsnobip Date: Thu, 2 Oct 2025 12:26:22 +0200 Subject: [PATCH 03/10] replace other references of `raise` with `throw` --- analysis/reanalyze/src/Common.ml | 6 +- analysis/reanalyze/src/Exception.ml | 73 ++++++++++--------- analysis/reanalyze/src/Log_.ml | 12 +-- .../deadcode/expected/exception.txt | 46 ++++++------ .../deadcode/src/exception/Exn.res | 34 ++++----- 5 files changed, 87 insertions(+), 84 deletions(-) diff --git a/analysis/reanalyze/src/Common.ml b/analysis/reanalyze/src/Common.ml index e0e7e592bd..9e4d1c3352 100644 --- a/analysis/reanalyze/src/Common.ml +++ b/analysis/reanalyze/src/Common.ml @@ -205,12 +205,12 @@ type line = {mutable declarations: decl list; original: string} module ExnSet = Set.Make (Exn) -type missingRaiseInfo = { +type missingThrowInfo = { exnName: string; exnTable: (Exn.t, LocSet.t) Hashtbl.t; locFull: Location.t; missingAnnotations: ExnSet.t; - raiseSet: ExnSet.t; + throwSet: ExnSet.t; } type severity = Warning | Error @@ -234,7 +234,7 @@ type lineAnnotation = (decl * line) option type description = | Circular of {message: string} | ExceptionAnalysis of {message: string} - | ExceptionAnalysisMissing of missingRaiseInfo + | ExceptionAnalysisMissing of missingThrowInfo | DeadModule of {message: string} | DeadOptional of {deadOptional: deadOptional; message: string} | DeadWarning of { diff --git a/analysis/reanalyze/src/Exception.ml b/analysis/reanalyze/src/Exception.ml index afc1ba3bbc..891869dc33 100644 --- a/analysis/reanalyze/src/Exception.ml +++ b/analysis/reanalyze/src/Exception.ml @@ -66,9 +66,9 @@ module Event = struct type kind = | Catches of t list (* with | E => ... *) | Call of {callee: Common.Path.t; modulePath: Common.Path.t} (* foo() *) - | DoesNotRaise of - t list (* DoesNotRaise(events) where events come from an expression *) - | Raises (** raise E *) + | DoesNotThrow of + t list (* DoesNotThrow(events) where events come from an expression *) + | Throws (** raise E *) and t = {exceptions: Exceptions.t; kind: kind; loc: Location.t} @@ -81,14 +81,14 @@ module Event = struct (modulePath |> Common.Path.toString) (Exceptions.pp ~exnTable:None) exceptions - | {kind = DoesNotRaise nestedEvents; loc} -> - Format.fprintf ppf "%s DoesNotRaise(%a)@." + | {kind = DoesNotThrow nestedEvents; loc} -> + Format.fprintf ppf "%s DoesNotThrow(%a)@." (loc.loc_start |> posToString) (fun ppf () -> nestedEvents |> List.iter (fun e -> Format.fprintf ppf "%a " print e)) () - | {kind = Raises; exceptions; loc} -> - Format.fprintf ppf "%s raises %a@." + | {kind = Throws; exceptions; loc} -> + Format.fprintf ppf "%s throws %a@." (loc.loc_start |> posToString) (Exceptions.pp ~exnTable:None) exceptions @@ -118,7 +118,7 @@ module Event = struct in let rec loop exnSet events = match events with - | ({kind = Raises; exceptions; loc} as ev) :: rest -> + | ({kind = Throws; exceptions; loc} as ev) :: rest -> if !Common.Cli.debug then Log_.item "%a@." print ev; exceptions |> Exceptions.iter (fun exn -> extendExnTable exn loc); loop (Exceptions.union exnSet exceptions) rest @@ -134,7 +134,7 @@ module Event = struct in exceptions |> Exceptions.iter (fun exn -> extendExnTable exn loc); loop (Exceptions.union exnSet exceptions) rest - | ({kind = DoesNotRaise nestedEvents; loc} as ev) :: rest -> + | ({kind = DoesNotThrow nestedEvents; loc} as ev) :: rest -> if !Common.Cli.debug then Log_.item "%a@." print ev; let nestedExceptions = loop Exceptions.empty nestedEvents in (if Exceptions.isEmpty nestedExceptions (* catch-all *) then @@ -148,8 +148,8 @@ module Event = struct { message = Format.asprintf - "@{%s@} does not raise and is annotated with \ - redundant @doesNotRaise" + "@{%s@} does not throw and is annotated with \ + redundant @doesNotThrow" (name |> Name.toString); })); loop exnSet rest @@ -188,13 +188,13 @@ module Checks = struct checks := {events; exceptions; loc; locFull; moduleName; exnName} :: !checks let doCheck {events; exceptions; loc; locFull; moduleName; exnName} = - let raiseSet, exnTable = events |> Event.combine ~moduleName in - let missingAnnotations = Exceptions.diff raiseSet exceptions in - let redundantAnnotations = Exceptions.diff exceptions raiseSet in + let throwSet, exnTable = events |> Event.combine ~moduleName in + let missingAnnotations = Exceptions.diff throwSet exceptions in + let redundantAnnotations = Exceptions.diff exceptions throwSet in (if not (Exceptions.isEmpty missingAnnotations) then let description = Common.ExceptionAnalysisMissing - {exnName; exnTable; raiseSet; missingAnnotations; locFull} + {exnName; exnTable; throwSet; missingAnnotations; locFull} in Log_.warning ~loc description); if not (Exceptions.isEmpty redundantAnnotations) then @@ -203,12 +203,12 @@ module Checks = struct { message = (let raisesDescription ppf () = - if raiseSet |> Exceptions.isEmpty then + if throwSet |> Exceptions.isEmpty then Format.fprintf ppf "raises nothing" else Format.fprintf ppf "might raise %a" (Exceptions.pp ~exnTable:(Some exnTable)) - raiseSet + throwSet in Format.asprintf "@{%s@} %a and is annotated with redundant @throws(%a)" @@ -249,7 +249,7 @@ let traverseAst () = case.c_guard |> iterExprOpt self; case.c_rhs |> iterExpr self) in - let isRaise s = s = "Pervasives.raise" || s = "Pervasives.throw" in + let isThrow s = s = "Pervasives.raise" || s = "Pervasives.throw" in let raiseArgs args = match args with | [(_, Some {Typedtree.exp_desc = Texp_construct ({txt}, _, _)})] -> @@ -258,26 +258,29 @@ let traverseAst () = [Exn.fromString "genericException"] |> Exceptions.fromList | _ -> [Exn.fromString "TODO_from_raise1"] |> Exceptions.fromList in - let doesNotRaise attributes = + let doesNotThrow attributes = attributes - |> Annotation.getAttributePayload (fun s -> - s = "doesNotRaise" || s = "doesnotraise" || s = "DoesNoRaise" - || s = "doesNotraise" || s = "doNotRaise" || s = "donotraise" - || s = "DoNoRaise" || s = "doNotraise") + |> Annotation.getAttributePayload (function + | "doesNotRaise" | "doesnotraise" | "DoesNoRaise" | "doesNotraise" + | "doNotRaise" | "donotraise" | "DoNoRaise" | "doNotraise" + | "doesNotThrow" | "doesnotthrow" | "DoesNoThrow" | "doesNotthrow" + | "doNotThrow" | "donotthrow" | "DoNoThrow" | "doNotthrow" -> + true + | _ -> false) <> None in let expr (self : Tast_mapper.mapper) (expr : Typedtree.expression) = let loc = expr.exp_loc in - let isDoesNoRaise = expr.exp_attributes |> doesNotRaise in + let isDoesNoThrow = expr.exp_attributes |> doesNotThrow in let oldEvents = !currentEvents in - if isDoesNoRaise then currentEvents := []; + if isDoesNoThrow then currentEvents := []; (match expr.exp_desc with | Texp_ident (callee_, _, _) -> let callee = callee_ |> Common.Path.fromPathT |> ModulePath.resolveAlias in let calleeName = callee |> Common.Path.toName in - if calleeName |> Name.toString |> isRaise then + if calleeName |> Name.toString |> isThrow then Log_.warning ~loc (Common.ExceptionAnalysis { @@ -299,17 +302,17 @@ let traverseAst () = args = [(_lbl1, Some {exp_desc = Texp_ident (callee, _, _)}); arg]; } when (* raise @@ Exn(...) *) - atat |> Path.name = "Pervasives.@@" && callee |> Path.name |> isRaise + atat |> Path.name = "Pervasives.@@" && callee |> Path.name |> isThrow -> let exceptions = [arg] |> raiseArgs in - currentEvents := {Event.exceptions; loc; kind = Raises} :: !currentEvents; + currentEvents := {Event.exceptions; loc; kind = Throws} :: !currentEvents; arg |> snd |> iterExprOpt self | Texp_apply {funct = {exp_desc = Texp_ident (callee, _, _)} as e; args} -> let calleeName = Path.name callee in - if calleeName |> isRaise then + if calleeName |> isThrow then let exceptions = args |> raiseArgs in currentEvents := - {Event.exceptions; loc; kind = Raises} :: !currentEvents + {Event.exceptions; loc; kind = Throws} :: !currentEvents else e |> iterExpr self; args |> List.iter (fun (_, eOpt) -> eOpt |> iterExprOpt self) | Texp_match (e, casesOk, casesExn, partial) -> @@ -332,7 +335,7 @@ let traverseAst () = { Event.exceptions = [Exn.matchFailure] |> Exceptions.fromList; loc; - kind = Raises; + kind = Throws; } :: !currentEvents | Texp_try (e, cases) -> @@ -348,19 +351,19 @@ let traverseAst () = {Event.exceptions; loc; kind = Catches !currentEvents} :: oldEvents; cases |> iterCases self | _ -> super.expr self expr |> ignore); - (if isDoesNoRaise then + (if isDoesNoThrow then let nestedEvents = !currentEvents in currentEvents := { Event.exceptions = Exceptions.empty; loc; - kind = DoesNotRaise nestedEvents; + kind = DoesNotThrow nestedEvents; } :: oldEvents); expr in let getExceptionsFromAnnotations attributes = - let raisesAnnotationPayload = + let throwsAnnotationPayload = attributes |> Annotation.getAttributePayload (fun s -> s = "throws" || s = "throw" || s = "raises" || s = "raise") @@ -380,7 +383,7 @@ let traverseAst () = |> List.concat |> Exceptions.fromList | _ -> Exceptions.empty in - match raisesAnnotationPayload with + match throwsAnnotationPayload with | None -> Exceptions.empty | Some payload -> payload |> getExceptions in diff --git a/analysis/reanalyze/src/Log_.ml b/analysis/reanalyze/src/Log_.ml index 744ace0ae4..ca333e1544 100644 --- a/analysis/reanalyze/src/Log_.ml +++ b/analysis/reanalyze/src/Log_.ml @@ -117,17 +117,17 @@ let logAdditionalInfo ~(description : description) = missingRaiseInfoToText missingRaiseInfo | _ -> "" -let missingRaiseInfoToMessage {exnTable; exnName; missingAnnotations; raiseSet} +let missingThrowInfoToMessage {exnTable; exnName; missingAnnotations; throwSet} = - let raisesTxt = - Format.asprintf "%a" (Exceptions.pp ~exnTable:(Some exnTable)) raiseSet + let throwsTxt = + Format.asprintf "%a" (Exceptions.pp ~exnTable:(Some exnTable)) throwSet in let missingTxt = Format.asprintf "%a" (Exceptions.pp ~exnTable:None) missingAnnotations in Format.asprintf - "@{%s@} might raise %s and is not annotated with @throws(%s)" exnName - raisesTxt missingTxt + "@{%s@} might throw %s and is not annotated with @throws(%s)" exnName + throwsTxt missingTxt let descriptionToMessage (description : description) = match description with @@ -138,7 +138,7 @@ let descriptionToMessage (description : description) = Format.asprintf "@{%s@} %s" path message | ExceptionAnalysis {message} -> message | ExceptionAnalysisMissing missingRaiseInfo -> - missingRaiseInfoToMessage missingRaiseInfo + missingThrowInfoToMessage missingRaiseInfo | Termination {message} -> message let descriptionToName (description : description) = diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/expected/exception.txt b/tests/analysis_tests/tests-reanalyze/deadcode/expected/exception.txt index 97da30a746..04132a8472 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/expected/exception.txt +++ b/tests/analysis_tests/tests-reanalyze/deadcode/expected/exception.txt @@ -2,63 +2,63 @@ Exception Analysis Exn.res:1:5-10 - raises might raise Not_found (Exn.res:1:19) and is not annotated with @throws(Not_found) + raises might throw Not_found (Exn.res:1:19) and is not annotated with @throws(Not_found) Exception Analysis Exn.res:19:5-28 - callsRaiseWithAnnotation might raise Not_found (Exn.res:19:31) and is not annotated with @throws(Not_found) + callsThrowWithAnnotation might throw Not_found (Exn.res:19:31) and is not annotated with @throws(Not_found) Exception Analysis Exn.res:22:5-42 - callsRaiseWithAnnotationAndIsAnnotated might raise Not_found (Exn.res:22:45) and is not annotated with @throws(Not_found) + callsThrowWithAnnotationAndIsAnnotated might throw Not_found (Exn.res:22:45) and is not annotated with @throws(Not_found) Exception Analysis Exn.res:22:5-42 - callsRaiseWithAnnotationAndIsAnnotated might raise Not_found (Exn.res:22:45) and is annotated with redundant @throws(A) + callsThrowWithAnnotationAndIsAnnotated might raise Not_found (Exn.res:22:45) and is annotated with redundant @throws(A) Exception Analysis Exn.res:24:5-19 - incompleteMatch might raise Match_failure (Exn.res:25:2) and is not annotated with @throws(Match_failure) + incompleteMatch might throw Match_failure (Exn.res:25:2) and is not annotated with @throws(Match_failure) Exception Analysis Exn.res:32:5-13 - twoRaises might raise [A (Exn.res:34:4), B (Exn.res:37:4)] and is not annotated with @throws([A, B]) + twoThrows might throw [A (Exn.res:34:4), B (Exn.res:37:4)] and is not annotated with @throws([A, B]) Exception Analysis Exn.res:41:5-14 - sequencing might raise A (Exn.res:42:2) and is not annotated with @throws(A) + sequencing might throw A (Exn.res:42:2) and is not annotated with @throws(A) Exception Analysis Exn.res:48:5-14 - wrongCatch might raise B (Exn.res:49:6) and is not annotated with @throws(B) + wrongCatch might throw B (Exn.res:49:6) and is not annotated with @throws(B) Exception Analysis Exn.res:54:5-15 - wrongCatch2 might raise [C (Exn.res:55:24), Match_failure (Exn.res:55:2)] and is not annotated with @throws([C, Match_failure]) + wrongCatch2 might throw [C (Exn.res:55:24), Match_failure (Exn.res:55:2)] and is not annotated with @throws([C, Match_failure]) Exception Analysis Exn.res:62:5-19 - raise2Annotate3 might raise [A (Exn.res:64:4), B (Exn.res:67:4)] and is annotated with redundant @throws(C) + throw2Annotate3 might raise [A (Exn.res:64:4), B (Exn.res:67:4)] and is annotated with redundant @throws(C) Exception Analysis Exn.res:73:5-24 - parse_json_from_file might raise Error (Exn.res:75:34) and is not annotated with @throws(Error) + parse_json_from_file might throw Error (Exn.res:75:34) and is not annotated with @throws(Error) Exception Analysis Exn.res:80:5-11 - reRaise might raise B (Exn.res:82:19) and is not annotated with @throws(B) + reThrow might throw B (Exn.res:82:19) and is not annotated with @throws(B) Exception Analysis Exn.res:91:5-22 - raiseInInternalLet might raise A (Exn.res:92:14) and is not annotated with @throws(A) + throwInInternalLet might throw A (Exn.res:92:14) and is not annotated with @throws(A) Exception Analysis Exn.res:96:5-16 - indirectCall might raise Not_found (Exn.res:96:25) and is not annotated with @throws(Not_found) + indirectCall might throw Not_found (Exn.res:96:25) and is not annotated with @throws(Not_found) Exception Analysis Exn.res:121:5-16 - severalCases might raise Failure (Exn.res:123:13 Exn.res:124:13 Exn.res:125:15) and is not annotated with @throws(Failure) + severalCases might throw Failure (Exn.res:123:13 Exn.res:124:13 Exn.res:125:15) and is not annotated with @throws(Failure) Exception Analysis Exn.res:133:5-23 @@ -66,34 +66,34 @@ Exception Analysis Exn.res:135:5-6 - _x might raise A (Exn.res:135:9) and is not annotated with @throws(A) + _x might throw A (Exn.res:135:9) and is not annotated with @throws(A) Exception Analysis Exn.res:137:5 - _ might raise A (Exn.res:137:8) and is not annotated with @throws(A) + _ might throw A (Exn.res:137:8) and is not annotated with @throws(A) Exception Analysis Exn.res:139:5-6 - () might raise A (Exn.res:139:9) and is not annotated with @throws(A) + () might throw A (Exn.res:139:9) and is not annotated with @throws(A) Exception Analysis Exn.res:141:1-16 - Toplevel expression might raise Not_found (Exn.res:141:0) and is not annotated with @throws(Not_found) + Toplevel expression might throw Not_found (Exn.res:141:0) and is not annotated with @throws(Not_found) Exception Analysis Exn.res:151:46-47 - expression does not raise and is annotated with redundant @doesNotRaise + expression does not throw and is annotated with redundant @doesNotThrow Exception Analysis Exn.res:151:5-21 - onResultPipeWrong might raise Assert_failure (Exn.res:151:50) and is not annotated with @throws(Assert_failure) + onResultPipeWrong might throw Assert_failure (Exn.res:151:50) and is not annotated with @throws(Assert_failure) Exception Analysis ExnA.res:1:5-7 - bar might raise Not_found (ExnA.res:1:16) and is not annotated with @throws(Not_found) + bar might throw Not_found (ExnA.res:1:16) and is not annotated with @throws(Not_found) Exception Analysis ExternalTest.res:7:5-24 - bigIntFromStringExn2 might raise JsExn (ExternalTest.res:7:35) and is not annotated with @throws(JsExn) + bigIntFromStringExn2 might throw JsExn (ExternalTest.res:7:35) and is not annotated with @throws(JsExn) Analysis reported 24 issues (Exception Analysis:24) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res index ed87e23ff9..37916f507e 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res @@ -9,17 +9,17 @@ let catches2 = switch () { | exception Not_found => () } -let raiseAndCatch = try throw(Not_found) catch { +let throwAndCatch = try throw(Not_found) catch { | _ => () } @throws(Not_found) -let raisesWithAnnotaion = () => throw(Not_found) +let throwsWithAnnotation = () => throw(Not_found) -let callsRaiseWithAnnotation = raisesWithAnnotaion() +let callsThrowWithAnnotation = throwsWithAnnotation() @throws(A) -let callsRaiseWithAnnotationAndIsAnnotated = raisesWithAnnotaion() +let callsThrowWithAnnotationAndIsAnnotated = throwsWithAnnotation() let incompleteMatch = l => switch l { @@ -29,7 +29,7 @@ let incompleteMatch = l => exception A exception B -let twoRaises = (x, y) => { +let twoThrows = (x, y) => { if x { throw(A) } @@ -59,7 +59,7 @@ let wrongCatch2 = b => } @throws([A, B, C]) -let raise2Annotate3 = (x, y) => { +let throw2Annotate3 = (x, y) => { if x { throw(A) } @@ -77,7 +77,7 @@ let parse_json_from_file = s => { } } -let reRaise = () => +let reThrow = () => switch throw(A) { | exception A => throw(B) | _ => 11 @@ -88,12 +88,12 @@ let switchWithCatchAll = switch throw(A) { | _ => 2 } -let raiseInInternalLet = b => { +let throwInInternalLet = b => { let a = b ? throw(A) : 22 a + 34 } -let indirectCall = () => raisesWithAnnotaion() +let indirectCall = () => throwsWithAnnotation() let array = a => a[2] @@ -107,13 +107,13 @@ let tryChar = v => { } @throws(Not_found) -let raiseAtAt = () => \"@@"(raise, Not_found) +let throwAtAt = () => \"@@"(throw, Not_found) @throws(Not_found) -let raisePipe = throw(Not_found) +let throwPipe = throw(Not_found) @throws(Not_found) -let raiseArrow = Not_found->raise +let throwArrow = Not_found->throw @throws(JsExn) let bar = () => Js.Json.parseExn("!!!") @@ -127,7 +127,7 @@ let severalCases = cases => } @throws(genericException) -let genericRaiseIsNotSupported = exn => throw(exn) +let genericThrowIsNotSupported = exn => throw(exn) @throws(Invalid_argument) let redundantAnnotation = () => () @@ -142,10 +142,10 @@ throw(Not_found) // Examples with pipe -let onFunction = () => (@doesNotRaise Belt.Array.getExn)([], 0) +let onFunction = () => (@doesNotThrow Belt.Array.getExn)([], 0) -let onResult = () => @doesNotRaise Belt.Array.getExn([], 0) +let onResult = () => @doesNotThrow Belt.Array.getExn([], 0) -let onFunctionPipe = () => []->(@doesNotRaise Belt.Array.getExn)(0) +let onFunctionPipe = () => []->(@doesNotThrow Belt.Array.getExn)(0) -let onResultPipeWrong = () => (@doesNotRaise [])->Belt.Array.getExn(0) +let onResultPipeWrong = () => (@doesNotThrow [])->Belt.Array.getExn(0) From 7276ad9b84b632fbf454fa2b83e358ffb1b1273c Mon Sep 17 00:00:00 2001 From: tsnobip Date: Thu, 2 Oct 2025 12:46:50 +0200 Subject: [PATCH 04/10] update "Contribute to the API Reference" --- CONTRIBUTING.md | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b1efc73834..b3061cd48d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -334,30 +334,15 @@ Note that there's currently still a manual step involved on [rescript-lang.org]( ## Contribute to the API Reference -The API reference is generated from doc comments in the source code. [Here](https://github.com/rescript-lang/rescript-compiler/blob/99650/jscomp/others/js_re.mli#L146-L161)'s a good example. +The API reference is generated from doc comments in the source code. [Here](https://github.com/rescript-lang/rescript/blob/57c696b1a38f53badaddcc082ed29188d80df70d/packages/%40rescript/runtime/Stdlib_String.resi#L441-L458)'s a good example. Some tips: -- The first sentence or line should be a very short summary. This is used in indexes and by tools like merlin. -- Ideally, every function should have **at least one** `@example`. -- Cross-reference another definition with `{! identifier}`. But use them sparingly, they’re a bit verbose (currently, at least). -- Wrap non-cross-referenced identifiers and other code in `[ ... ]`. -- Escape `{`, `}`, `[`, `]` and `@` using `\`. -- It’s possible to use `{%html ...}` to generate custom html, but use this very, very sparingly. -- A number of "documentation tags" are provided that would be nice to use, but unfortunately they’re often not supported for \`external\`s. Which is of course most of the API. -- `@param` usually doesn’t work. Use `{b } ...` instead -- `@returns` usually doesn’t work. Use `{b returns} ...` instead. +- The first sentence or line should show the function call with a very short summary. +- Ideally, every function should have an `## Examples` section with **at least one** example. The examples are compiled to check that they are correct. Use `==` to generate tests from the examples. - Always use `@deprecated` when applicable. -- Always use `@raise` when applicable. -- Always provide a `@see` tag pointing to MDN for more information when available. - -See [Ocamldoc documentation](http://caml.inria.fr/pub/docs/manual-ocaml/ocamldoc.html#sec333) for more details. - -To generate the html: - -```sh -../scripts/ninja docs -``` +- Always use `@throw` when applicable. +- Always provide a `See` section pointing to MDN for more information when available. ## Contribute to JSX `domProps` @@ -389,6 +374,7 @@ Adding a new entry there requires re-running the analysis tests. Follow these st (If a `make` command fails, consider using the [DevContainer](#b-devcontainer).) Finally, add a line to [CHANGELOG.md](CHANGELOG.md), using the `#### :nail_care: Polish` section. + ## Code structure The highlevel architecture is illustrated as below: From 30d09c9e606329268271dead6c22920368dcd2dc Mon Sep 17 00:00:00 2001 From: tsnobip Date: Thu, 2 Oct 2025 12:48:57 +0200 Subject: [PATCH 05/10] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 491c004eb1..af75dabd6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ #### :nail_care: Polish - Rewatch cli: do not show build command options in the root help. https://github.com/rescript-lang/rescript/pull/7715 +- Deprecate reanalyze `@raises` in favor of `@throws`. https://github.com/rescript-lang/rescript/pull/7932 #### :house: Internal From 9cce9febbf4ac014b563a3e1d742765624879d51 Mon Sep 17 00:00:00 2001 From: tsnobip Date: Thu, 2 Oct 2025 12:55:24 +0200 Subject: [PATCH 06/10] update docs some more --- analysis/src/CompletionDecorators.ml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/analysis/src/CompletionDecorators.ml b/analysis/src/CompletionDecorators.ml index a594a2469f..e03a06f8cd 100644 --- a/analysis/src/CompletionDecorators.ml +++ b/analysis/src/CompletionDecorators.ml @@ -41,12 +41,24 @@ Alternatively, use the `@@deprecated` decorator to add a deprecation warning to ( "doesNotRaise", None, [ - {|The `@doesNotRaise` decorator is for reanalyze, a static analysis tool for ReScript that can perform exception analysis. + {|The `@doesNotRaise` decorator is deprecated. Please use `@doesNotThrow` instead. -`@doesNotRaise` is uses to override the analysis and state that an expression does not raise any exceptions, +`@doesNotRaise` is uses to override the analysis and state that an expression does not throw any exceptions, even though the analysis reports otherwise. This can happen for example in the case of array access where the analysis does not perform range checks but takes a conservative stance that any access -could potentially raise. +could potentially throw. +[Read more and see examples in the documentation](https://github.com/rescript-association/reanalyze/blob/master/EXCEPTION.md). +> Hint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!|}; + ] ); + ( "doesNotThrow", + None, + [ + {|The `@doesNotThrow` decorator is for reanalyze, a static analysis tool for ReScript that can perform exception analysis. + +`@doesNotThrow` is uses to override the analysis and state that an expression does not throw any exceptions, +even though the analysis reports otherwise. This can happen for example in the case of array access where +the analysis does not perform range checks but takes a conservative stance that any access +could potentially throw. [Read more and see examples in the documentation](https://github.com/rescript-association/reanalyze/blob/master/EXCEPTION.md). > Hint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!|}; ] ); @@ -151,7 +163,7 @@ The `@new` decorator is used whenever you need to bind to a JavaScript class con [ {|The `@raises` decorator is deprecated. Please use `@throws` instead. -`@raises` acknowledges that a function can raise exceptions that are not caught, and suppresses +`@raises` acknowledges that a function can throw exceptions that are not caught, and suppresses a warning in that case. Callers of the functions are then subjected to the same rule. Example `@raises(Exn)` or `@raises([E1, E2, E3])` for multiple exceptions. [Read more and see examples in the documentation](https://github.com/rescript-association/reanalyze/blob/master/EXCEPTION.md). @@ -162,7 +174,7 @@ Example `@raises(Exn)` or `@raises([E1, E2, E3])` for multiple exceptions. [ {|The `@throws` decorator is for reanalyze, a static analysis tool for ReScript that can perform exception analysis. -`@throws` acknowledges that a function can raise exceptions that are not caught, and suppresses +`@throws` acknowledges that a function can throw exceptions that are not caught, and suppresses a warning in that case. Callers of the functions are then subjected to the same rule. Example `@throws(Exn)` or `@throws([E1, E2, E3])` for multiple exceptions. [Read more and see examples in the documentation](https://github.com/rescript-association/reanalyze/blob/master/EXCEPTION.md). From 9acd5335817d421b586d58588357c465dc2664fd Mon Sep 17 00:00:00 2001 From: tsnobip Date: Fri, 3 Oct 2025 09:03:25 +0200 Subject: [PATCH 07/10] rename some more raises --- analysis/reanalyze/src/Exception.ml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/analysis/reanalyze/src/Exception.ml b/analysis/reanalyze/src/Exception.ml index 891869dc33..ce33c0fbd5 100644 --- a/analysis/reanalyze/src/Exception.ml +++ b/analysis/reanalyze/src/Exception.ml @@ -68,7 +68,7 @@ module Event = struct | Call of {callee: Common.Path.t; modulePath: Common.Path.t} (* foo() *) | DoesNotThrow of t list (* DoesNotThrow(events) where events come from an expression *) - | Throws (** raise E *) + | Throws (** throw E *) and t = {exceptions: Exceptions.t; kind: kind; loc: Location.t} @@ -158,12 +158,12 @@ module Event = struct if Exceptions.isEmpty exceptions then loop exnSet rest else let nestedExceptions = loop Exceptions.empty nestedEvents in - let newRaises = Exceptions.diff nestedExceptions exceptions in + let newThrows = Exceptions.diff nestedExceptions exceptions in exceptions |> Exceptions.iter (fun exn -> nestedEvents |> List.iter (fun event -> shrinkExnTable exn event.loc)); - loop (Exceptions.union exnSet newRaises) rest + loop (Exceptions.union exnSet newThrows) rest | [] -> exnSet in let exnSet = loop Exceptions.empty events in @@ -202,17 +202,17 @@ module Checks = struct (Common.ExceptionAnalysis { message = - (let raisesDescription ppf () = + (let throwsDescription ppf () = if throwSet |> Exceptions.isEmpty then - Format.fprintf ppf "raises nothing" + Format.fprintf ppf "throws nothing" else - Format.fprintf ppf "might raise %a" + Format.fprintf ppf "might throw %a" (Exceptions.pp ~exnTable:(Some exnTable)) throwSet in Format.asprintf "@{%s@} %a and is annotated with redundant @throws(%a)" - exnName raisesDescription () + exnName throwsDescription () (Exceptions.pp ~exnTable:None) redundantAnnotations); }) @@ -250,7 +250,7 @@ let traverseAst () = case.c_rhs |> iterExpr self) in let isThrow s = s = "Pervasives.raise" || s = "Pervasives.throw" in - let raiseArgs args = + let throwArgs args = match args with | [(_, Some {Typedtree.exp_desc = Texp_construct ({txt}, _, _)})] -> [Exn.fromLid txt] |> Exceptions.fromList @@ -304,13 +304,13 @@ let traverseAst () = when (* raise @@ Exn(...) *) atat |> Path.name = "Pervasives.@@" && callee |> Path.name |> isThrow -> - let exceptions = [arg] |> raiseArgs in + let exceptions = [arg] |> throwArgs in currentEvents := {Event.exceptions; loc; kind = Throws} :: !currentEvents; arg |> snd |> iterExprOpt self | Texp_apply {funct = {exp_desc = Texp_ident (callee, _, _)} as e; args} -> let calleeName = Path.name callee in if calleeName |> isThrow then - let exceptions = args |> raiseArgs in + let exceptions = args |> throwArgs in currentEvents := {Event.exceptions; loc; kind = Throws} :: !currentEvents else e |> iterExpr self; From 4f5313a247827327d843642fcbda519f7962e01d Mon Sep 17 00:00:00 2001 From: tsnobip Date: Fri, 3 Oct 2025 09:15:27 +0200 Subject: [PATCH 08/10] rename raise to throw in API docs --- packages/@rescript/runtime/Belt.res | 4 +-- packages/@rescript/runtime/Belt_Array.resi | 10 +++--- packages/@rescript/runtime/Belt_List.res | 6 ++-- packages/@rescript/runtime/Belt_List.resi | 24 ++++++------- packages/@rescript/runtime/Belt_Map.resi | 6 ++-- packages/@rescript/runtime/Belt_MapInt.resi | 2 +- .../@rescript/runtime/Belt_MapString.resi | 2 +- .../@rescript/runtime/Belt_MutableMap.resi | 2 +- .../@rescript/runtime/Belt_MutableMapInt.resi | 2 +- .../runtime/Belt_MutableMapString.resi | 2 +- .../@rescript/runtime/Belt_MutableQueue.resi | 8 ++--- .../@rescript/runtime/Belt_MutableSet.resi | 6 ++-- .../@rescript/runtime/Belt_MutableSetInt.resi | 2 +- .../runtime/Belt_MutableSetString.resi | 2 +- packages/@rescript/runtime/Belt_Option.resi | 8 ++--- packages/@rescript/runtime/Belt_Result.resi | 8 ++--- packages/@rescript/runtime/Belt_Set.resi | 6 ++-- packages/@rescript/runtime/Belt_SetDict.resi | 6 ++-- packages/@rescript/runtime/Belt_SetInt.resi | 2 +- .../@rescript/runtime/Belt_SetString.resi | 2 +- .../runtime/Belt_internalAVLset.resi | 2 +- .../runtime/Belt_internalAVLtree.resi | 2 +- packages/@rescript/runtime/Js_float.res | 14 ++++---- packages/@rescript/runtime/Js_int.res | 10 +++--- packages/@rescript/runtime/Js_json.res | 2 +- packages/@rescript/runtime/Js_json.resi | 4 +-- packages/@rescript/runtime/Js_math.res | 4 +-- packages/@rescript/runtime/Js_string.res | 6 ++-- packages/@rescript/runtime/Js_string2.res | 6 ++-- packages/@rescript/runtime/Js_typed_array.res | 36 +++++++++---------- .../@rescript/runtime/Js_typed_array2.res | 36 +++++++++---------- .../@rescript/runtime/Primitive_object.res | 4 +-- packages/@rescript/runtime/Stdlib.res | 2 +- packages/@rescript/runtime/Stdlib_Error.resi | 4 +-- packages/@rescript/runtime/Stdlib_Int.resi | 2 +- packages/@rescript/runtime/Stdlib_JSON.resi | 32 ++++++++--------- packages/@rescript/runtime/Stdlib_Lazy.resi | 26 +++++++------- packages/@rescript/runtime/Stdlib_List.resi | 12 +++---- packages/@rescript/runtime/Stdlib_Math.resi | 4 +-- packages/@rescript/runtime/Stdlib_Null.resi | 10 +++--- .../@rescript/runtime/Stdlib_Nullable.resi | 10 +++--- .../@rescript/runtime/Stdlib_Promise.resi | 2 +- .../@rescript/runtime/cppo/belt_Set.resi.cppo | 2 +- packages/@rescript/runtime/cppo/map.resi.cppo | 2 +- .../@rescript/runtime/cppo/mapm.resi.cppo | 2 +- .../@rescript/runtime/cppo/setm.resi.cppo | 2 +- packages/@rescript/runtime/lib/es6/Js_json.js | 2 +- packages/@rescript/runtime/lib/js/Js_json.js | 2 +- 48 files changed, 176 insertions(+), 176 deletions(-) diff --git a/packages/@rescript/runtime/Belt.res b/packages/@rescript/runtime/Belt.res index 059ecca9fe..4845669371 100644 --- a/packages/@rescript/runtime/Belt.res +++ b/packages/@rescript/runtime/Belt.res @@ -99,7 +99,7 @@ One common confusion comes from the way Belt handles array access. It differs fr let letters = ["a", "b", "c"] let a = letters[0] // a == "a" let capitalA = Js.String.toUpperCase(a) -let k = letters[10] // Raises an exception! The 10th index doesn't exist. +let k = letters[10] // Throws an exception! The 10th index doesn't exist. ``` Because Belt avoids exceptions and returns `options` instead, this code behaves differently: @@ -114,7 +114,7 @@ let captialA = Js.String.toUpperCase(a) // Type error! This code will not compil let k = letters[10] // k == None ``` -Although we've fixed the problem where `k` raises an exception, we now have a type error when trying to capitalize `a`. There are a few things going on here: +Although we've fixed the problem where `k` throws an exception, we now have a type error when trying to capitalize `a`. There are a few things going on here: - Reason transforms array index access to the function `Array.get`. So `letters[0]` is the same as `Array.get(letters, 0)`. - The compiler uses whichever `Array` module is in scope. If you `open Belt`, then it uses `Belt.Array`. diff --git a/packages/@rescript/runtime/Belt_Array.resi b/packages/@rescript/runtime/Belt_Array.resi index ffa41799bc..11aac20e0c 100644 --- a/packages/@rescript/runtime/Belt_Array.resi +++ b/packages/@rescript/runtime/Belt_Array.resi @@ -47,13 +47,13 @@ Belt.Array.get(["a", "b", "c"], -1) == None let get: (t<'a>, int) => option<'a> /** -Raise an exception if `i` is out of range. +Throw an exception if `i` is out of range. Otherwise return the value at index `i` in `arr`. */ let getExn: (t<'a>, int) => 'a /** -Raise an exception if `i` is out of range. +Throw an exception if `i` is out of range. Otherwise return the value at index `i` in `arr`. */ let getOrThrow: (t<'a>, int) => 'a @@ -83,12 +83,12 @@ with `x`. Returning `false` means not updated due to out of range. let set: (t<'a>, int, 'a) => bool /** -`setExn(arr, i, x)` raise an exception if `i` is out of range. +`setExn(arr, i, x)` throw an exception if `i` is out of range. */ let setExn: (t<'a>, int, 'a) => unit /** -`setOrThrow(arr, i, x)` raise an exception if `i` is out of range. +`setOrThrow(arr, i, x)` throw an exception if `i` is out of range. */ let setOrThrow: (t<'a>, int, 'a) => unit @@ -774,7 +774,7 @@ let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool /** Unsafe `truncateToLengthUnsafe(xs, n)` sets length of array `xs` to `n`. If `n` is greater than the length of `xs`; the extra elements are set to `Js.Null_undefined.null`. -If `n` is less than zero; raises a `RangeError`. +If `n` is less than zero; throws a `RangeError`. ## Examples diff --git a/packages/@rescript/runtime/Belt_List.res b/packages/@rescript/runtime/Belt_List.res index 1b657ae906..74f4e2d3d0 100644 --- a/packages/@rescript/runtime/Belt_List.res +++ b/packages/@rescript/runtime/Belt_List.res @@ -494,9 +494,9 @@ let shuffle = xs => { /* fillAuxMap arr 0 x f; */ /* J.array arr */ -/* TODO: best practice about raising excpetion - 1. raise OCaml exception, no stacktrace - 2. raise JS exception, how to pattern match +/* TODO: best practice about raising exception + 1. throw OCaml exception, no stacktrace + 2. throw JS exception, how to pattern match */ let rec reverseConcat = (l1, l2) => diff --git a/packages/@rescript/runtime/Belt_List.resi b/packages/@rescript/runtime/Belt_List.resi index b51ef12229..fabab345ec 100644 --- a/packages/@rescript/runtime/Belt_List.resi +++ b/packages/@rescript/runtime/Belt_List.resi @@ -63,7 +63,7 @@ Belt.List.head(list{1, 2, 3}) == Some(1) let head: t<'a> => option<'a> /** -Same as `Belt.List.head` but raises an exception if `someList` is empty. Use +Same as `Belt.List.head` but throws an exception if `someList` is empty. Use with care. ## Examples @@ -72,7 +72,7 @@ with care. Belt.List.headExn(list{1, 2, 3}) == 1 switch Belt.List.headExn(list{}) { -// Raises an Error +// Throws an Error | exception _ => assert(true) | _ => assert(false) } @@ -81,7 +81,7 @@ switch Belt.List.headExn(list{}) { let headExn: t<'a> => 'a /** -Same as `Belt.List.head` but raises an exception if `someList` is empty. Use +Same as `Belt.List.head` but throws an exception if `someList` is empty. Use with care. ## Examples @@ -90,7 +90,7 @@ with care. Belt.List.headOrThrow(list{1, 2, 3}) == 1 switch Belt.List.headOrThrow(list{}) { -// Raises an Error +// Throws an Error | exception _ => assert(true) | _ => assert(false) } @@ -113,7 +113,7 @@ Belt.List.tail(list{}) == None let tail: t<'a> => option> /** -Same as `Belt.List.tail` but raises an exception if `someList` is empty. Use +Same as `Belt.List.tail` but throws an exception if `someList` is empty. Use with care. ## Examples @@ -122,7 +122,7 @@ with care. Belt.List.tailExn(list{1, 2, 3}) == list{2, 3} switch Belt.List.tailExn(list{}) { -// Raises an Error +// Throws an Error | exception _ => assert(true) | _ => assert(false) } @@ -131,7 +131,7 @@ switch Belt.List.tailExn(list{}) { let tailExn: t<'a> => t<'a> /** -Same as `Belt.List.tail` but raises an exception if `someList` is empty. Use +Same as `Belt.List.tail` but throws an exception if `someList` is empty. Use with care. ## Examples @@ -140,7 +140,7 @@ with care. Belt.List.tailOrThrow(list{1, 2, 3}) == list{2, 3} switch Belt.List.tailOrThrow(list{}) { -// Raises an Error +// Throws an Error | exception _ => assert(true) | _ => assert(false) } @@ -178,7 +178,7 @@ abc->Belt.List.get(4) == None let get: (t<'a>, int) => option<'a> /** -Same as `Belt.List.get` but raises an exception if `index` is larger than the +Same as `Belt.List.get` but throws an exception if `index` is larger than the length. Use with care. ## Examples @@ -189,7 +189,7 @@ let abc = list{"A", "B", "C"} abc->Belt.List.getExn(1) == "B" switch abc->Belt.List.getExn(4) { -// Raises an Error +// Throws an Error | exception _ => assert(true) | _ => assert(false) } @@ -198,7 +198,7 @@ switch abc->Belt.List.getExn(4) { let getExn: (t<'a>, int) => 'a /** -Same as `Belt.List.get` but raises an exception if `index` is larger than the +Same as `Belt.List.get` but throws an exception if `index` is larger than the length. Use with care. ## Examples @@ -209,7 +209,7 @@ let abc = list{"A", "B", "C"} abc->Belt.List.getOrThrow(1) == "B" switch abc->Belt.List.getOrThrow(4) { -// Raises an Error +// Throws an Error | exception _ => assert(true) | _ => assert(false) } diff --git a/packages/@rescript/runtime/Belt_Map.resi b/packages/@rescript/runtime/Belt_Map.resi index 083f1470de..f35a589ebd 100644 --- a/packages/@rescript/runtime/Belt_Map.resi +++ b/packages/@rescript/runtime/Belt_Map.resi @@ -359,7 +359,7 @@ let getWithDefault: (t<'k, 'v, 'id>, 'k, 'v) => 'v See `Belt.Map.get` -raise when `k` not exist +throw when `k` not exist */ let getExn: (t<'k, 'v, 'id>, 'k) => 'v @@ -368,7 +368,7 @@ let getExn: (t<'k, 'v, 'id>, 'k) => 'v See `Belt.Map.get` -raise when `k` not exist +throw when `k` not exist */ let getOrThrow: (t<'k, 'v, 'id>, 'k) => 'v @@ -535,6 +535,6 @@ Returns the packed collection. let packIdData: (~id: id<'k, 'id>, ~data: Belt_MapDict.t<'k, 'v, 'id>) => t<'k, 'v, 'id> /** -**raise** when invariant is not held +**throw** when invariant is not held */ let checkInvariantInternal: t<_> => unit diff --git a/packages/@rescript/runtime/Belt_MapInt.resi b/packages/@rescript/runtime/Belt_MapInt.resi index 28aea4e794..aa71c5e1c2 100644 --- a/packages/@rescript/runtime/Belt_MapInt.resi +++ b/packages/@rescript/runtime/Belt_MapInt.resi @@ -117,7 +117,7 @@ let getExn: (t<'v>, key) => 'v let getOrThrow: (t<'v>, key) => 'v /** -**raise** when invariant is not held +**throw** when invariant is not held */ let checkInvariantInternal: t<_> => unit diff --git a/packages/@rescript/runtime/Belt_MapString.resi b/packages/@rescript/runtime/Belt_MapString.resi index 17a1299953..0456a74511 100644 --- a/packages/@rescript/runtime/Belt_MapString.resi +++ b/packages/@rescript/runtime/Belt_MapString.resi @@ -117,7 +117,7 @@ let getExn: (t<'v>, key) => 'v let getOrThrow: (t<'v>, key) => 'v /** -**raise** when invariant is not held +**throw** when invariant is not held */ let checkInvariantInternal: t<_> => unit diff --git a/packages/@rescript/runtime/Belt_MutableMap.resi b/packages/@rescript/runtime/Belt_MutableMap.resi index 71cd98d1dc..58d15ac4a5 100644 --- a/packages/@rescript/runtime/Belt_MutableMap.resi +++ b/packages/@rescript/runtime/Belt_MutableMap.resi @@ -122,7 +122,7 @@ let getUndefined: (t<'k, 'a, 'id>, 'k) => Js.undefined<'a> let getWithDefault: (t<'k, 'a, 'id>, 'k, 'a) => 'a let getExn: (t<'k, 'a, 'id>, 'k) => 'a let getOrThrow: (t<'k, 'a, 'id>, 'k) => 'a -/** Raise when invariant is not held. */ +/** Throw when invariant is not held. */ let checkInvariantInternal: t<_> => unit /* ************************************************************************** */ diff --git a/packages/@rescript/runtime/Belt_MutableMapInt.resi b/packages/@rescript/runtime/Belt_MutableMapInt.resi index 50137e3745..1813769910 100644 --- a/packages/@rescript/runtime/Belt_MutableMapInt.resi +++ b/packages/@rescript/runtime/Belt_MutableMapInt.resi @@ -109,7 +109,7 @@ let getExn: (t<'a>, key) => 'a let getOrThrow: (t<'a>, key) => 'a /** - **raise** when invariant is not held + **Throw** when invariant is not held */ let checkInvariantInternal: t<_> => unit diff --git a/packages/@rescript/runtime/Belt_MutableMapString.resi b/packages/@rescript/runtime/Belt_MutableMapString.resi index 5267799000..2a5b955ffd 100644 --- a/packages/@rescript/runtime/Belt_MutableMapString.resi +++ b/packages/@rescript/runtime/Belt_MutableMapString.resi @@ -109,7 +109,7 @@ let getExn: (t<'a>, key) => 'a let getOrThrow: (t<'a>, key) => 'a /** - **raise** when invariant is not held + **throw** when invariant is not held */ let checkInvariantInternal: t<_> => unit diff --git a/packages/@rescript/runtime/Belt_MutableQueue.resi b/packages/@rescript/runtime/Belt_MutableQueue.resi index 6a6a10be18..515d6b40f7 100644 --- a/packages/@rescript/runtime/Belt_MutableQueue.resi +++ b/packages/@rescript/runtime/Belt_MutableQueue.resi @@ -59,12 +59,12 @@ let peek: t<'a> => option<'a> let peekUndefined: t<'a> => Js.undefined<'a> /** -`peekExn(q)` raises an exception if `q` is empty. +`peekExn(q)` throws an exception if `q` is empty. */ let peekExn: t<'a> => 'a /** -`peekOrThrow(q)` raises an exception if `q` is empty. +`peekOrThrow(q)` throws an exception if `q` is empty. */ let peekOrThrow: t<'a> => 'a @@ -80,12 +80,12 @@ return `undefined` if it is already empty. let popUndefined: t<'a> => Js.undefined<'a> /** -`popExn(q)` raise an exception if q is empty. +`popExn(q)` throw an exception if q is empty. */ let popExn: t<'a> => 'a /** -`popOrThrow(q)` raise an exception if q is empty. +`popOrThrow(q)` throw an exception if q is empty. */ let popOrThrow: t<'a> => 'a diff --git a/packages/@rescript/runtime/Belt_MutableSet.resi b/packages/@rescript/runtime/Belt_MutableSet.resi index f595a91b29..6c5c4254b3 100644 --- a/packages/@rescript/runtime/Belt_MutableSet.resi +++ b/packages/@rescript/runtime/Belt_MutableSet.resi @@ -633,12 +633,12 @@ Same as `Belt.MutableSet.get` but returns `undefined` when element does not exis let getUndefined: (t<'value, 'id>, 'value) => Js.undefined<'value> /** -Same as `Belt.MutableSet.get` but raise when element does not exist. +Same as `Belt.MutableSet.get` but throw when element does not exist. */ let getExn: (t<'value, 'id>, 'value) => 'value /** -Same as `Belt.MutableSet.get` but raise when element does not exist. +Same as `Belt.MutableSet.get` but throw when element does not exist. */ let getOrThrow: (t<'value, 'id>, 'value) => 'value @@ -665,7 +665,7 @@ larger->Belt.MutableSet.toArray == [4, 5] let split: (t<'value, 'id>, 'value) => ((t<'value, 'id>, t<'value, 'id>), bool) /** -**raise** when invariant is not held +**throw** when invariant is not held */ let checkInvariantInternal: t<_> => unit diff --git a/packages/@rescript/runtime/Belt_MutableSetInt.resi b/packages/@rescript/runtime/Belt_MutableSetInt.resi index 7d5bf2580d..54cb3d7bdd 100644 --- a/packages/@rescript/runtime/Belt_MutableSetInt.resi +++ b/packages/@rescript/runtime/Belt_MutableSetInt.resi @@ -133,6 +133,6 @@ let getOrThrow: (t, value) => value let split: (t, value) => ((t, t), bool) /** -**raise** when invariant is not held +**throw** when invariant is not held */ let checkInvariantInternal: t => unit diff --git a/packages/@rescript/runtime/Belt_MutableSetString.resi b/packages/@rescript/runtime/Belt_MutableSetString.resi index d2fd827e4c..d232c3a648 100644 --- a/packages/@rescript/runtime/Belt_MutableSetString.resi +++ b/packages/@rescript/runtime/Belt_MutableSetString.resi @@ -133,6 +133,6 @@ let getOrThrow: (t, value) => value let split: (t, value) => ((t, t), bool) /** -**raise** when invariant is not held +**throw** when invariant is not held */ let checkInvariantInternal: t => unit diff --git a/packages/@rescript/runtime/Belt_Option.resi b/packages/@rescript/runtime/Belt_Option.resi index c0a2a60a4e..d1c9ca209c 100644 --- a/packages/@rescript/runtime/Belt_Option.resi +++ b/packages/@rescript/runtime/Belt_Option.resi @@ -74,7 +74,7 @@ Belt.Option.forEach(None, x => Js.log(x)) /* returns () */ let forEach: (option<'a>, 'a => unit) => unit /** -Raises an Error in case `None` is provided. Use with care. +Throws an Error in case `None` is provided. Use with care. ## Examples @@ -82,7 +82,7 @@ Raises an Error in case `None` is provided. Use with care. Some(3)->Belt.Option.getExn == 3 switch Belt.Option.getExn(None) { -// Raises an exception +// Throws an exception | exception _ => assert(true) | _ => assert(false) } @@ -91,7 +91,7 @@ switch Belt.Option.getExn(None) { let getExn: option<'a> => 'a /** -Raises an Error in case `None` is provided. Use with care. +Throws an Error in case `None` is provided. Use with care. ## Examples @@ -99,7 +99,7 @@ Raises an Error in case `None` is provided. Use with care. Some(3)->Belt.Option.getOrThrow == 3 switch Belt.Option.getOrThrow(None) { -// Raises an exception +// Throws an exception | exception _ => assert(true) | _ => assert(false) } diff --git a/packages/@rescript/runtime/Belt_Result.resi b/packages/@rescript/runtime/Belt_Result.resi index c5873d31e6..bed815fabc 100644 --- a/packages/@rescript/runtime/Belt_Result.resi +++ b/packages/@rescript/runtime/Belt_Result.resi @@ -34,7 +34,7 @@ type t<'a, 'b> = result<'a, 'b> = | Error('b) /** -`getExn(res)`: when `res` is `Ok(n)`, returns `n` when `res` is `Error(m)`, raise an exception +`getExn(res)`: when `res` is `Ok(n)`, returns `n` when `res` is `Error(m)`, throw an exception ## Examples @@ -42,7 +42,7 @@ type t<'a, 'b> = result<'a, 'b> = Belt.Result.Ok(42)->Belt.Result.getExn == 42 switch Belt.Result.getExn(Belt.Result.Error("Invalid data")) { -// raise a exception +// throw a exception | exception _ => assert(true) | _ => assert(false) } @@ -51,7 +51,7 @@ switch Belt.Result.getExn(Belt.Result.Error("Invalid data")) { let getExn: t<'a, 'b> => 'a /** -`getOrThrow(res)`: when `res` is `Ok(n)`, returns `n` when `res` is `Error(m)`, raise an exception +`getOrThrow(res)`: when `res` is `Ok(n)`, returns `n` when `res` is `Error(m)`, throw an exception ## Examples @@ -59,7 +59,7 @@ let getExn: t<'a, 'b> => 'a Belt.Result.Ok(42)->Belt.Result.getOrThrow == 42 switch Belt.Result.getOrThrow(Belt.Result.Error("Invalid data")) { -// raise a exception +// throw a exception | exception _ => assert(true) | _ => assert(false) } diff --git a/packages/@rescript/runtime/Belt_Set.resi b/packages/@rescript/runtime/Belt_Set.resi index fca4aefbd8..1d55893a32 100644 --- a/packages/@rescript/runtime/Belt_Set.resi +++ b/packages/@rescript/runtime/Belt_Set.resi @@ -676,12 +676,12 @@ Same as [get](#get) but returns `undefined` when element does not exist. let getUndefined: (t<'value, 'id>, 'value) => Js.undefined<'value> /** -Same as [get](#get) but raise when element does not exist. +Same as [get](#get) but throw when element does not exist. */ let getExn: (t<'value, 'id>, 'value) => 'value /** -Same as [get](#get) but raise when element does not exist. +Same as [get](#get) but throw when element does not exist. */ let getOrThrow: (t<'value, 'id>, 'value) => 'value @@ -708,7 +708,7 @@ larger->Belt.Set.toArray == [4, 5] let split: (t<'value, 'id>, 'value) => ((t<'value, 'id>, t<'value, 'id>), bool) /** -**raise** when invariant is not held +**throw** when invariant is not held */ let checkInvariantInternal: t<_> => unit diff --git a/packages/@rescript/runtime/Belt_SetDict.resi b/packages/@rescript/runtime/Belt_SetDict.resi index 95a26dba93..ec7dbd5d81 100644 --- a/packages/@rescript/runtime/Belt_SetDict.resi +++ b/packages/@rescript/runtime/Belt_SetDict.resi @@ -603,12 +603,12 @@ Same as [get](#get) but returns `undefined` when element does not exist. let getUndefined: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => Js.undefined<'value> /** -Same as [get](#get) but raise when element does not exist. +Same as [get](#get) but throw when element does not exist. */ let getExn: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => 'value /** -Same as [get](#get) but raise when element does not exist. +Same as [get](#get) but throw when element does not exist. */ let getOrThrow: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => 'value @@ -639,6 +639,6 @@ let split: ( ) => ((t<'value, 'id>, t<'value, 'id>), bool) /** -**raise** when invariant is not held +**throw** when invariant is not held */ let checkInvariantInternal: t<_> => unit diff --git a/packages/@rescript/runtime/Belt_SetInt.resi b/packages/@rescript/runtime/Belt_SetInt.resi index e6337a1df8..5fd14dfe27 100644 --- a/packages/@rescript/runtime/Belt_SetInt.resi +++ b/packages/@rescript/runtime/Belt_SetInt.resi @@ -165,6 +165,6 @@ element equal to `x`, or `true` if `s` contains an element equal to `x`. let split: (t, value) => ((t, t), bool) /** -**raise** when invariant is not held +**throw** when invariant is not held */ let checkInvariantInternal: t => unit diff --git a/packages/@rescript/runtime/Belt_SetString.resi b/packages/@rescript/runtime/Belt_SetString.resi index 06156c9fc6..81a8719af6 100644 --- a/packages/@rescript/runtime/Belt_SetString.resi +++ b/packages/@rescript/runtime/Belt_SetString.resi @@ -165,6 +165,6 @@ element equal to `x`, or `true` if `s` contains an element equal to `x`. let split: (t, value) => ((t, t), bool) /** -**raise** when invariant is not held +**throw** when invariant is not held */ let checkInvariantInternal: t => unit diff --git a/packages/@rescript/runtime/Belt_internalAVLset.resi b/packages/@rescript/runtime/Belt_internalAVLset.resi index d66a8a4488..cb3b3e427e 100644 --- a/packages/@rescript/runtime/Belt_internalAVLset.resi +++ b/packages/@rescript/runtime/Belt_internalAVLset.resi @@ -80,7 +80,7 @@ let size: t<'a> => int let toList: t<'a> => list<'a> /** -**raise** when invariant is not held +**throw** when invariant is not held */ let checkInvariantInternal: t<_> => unit diff --git a/packages/@rescript/runtime/Belt_internalAVLtree.resi b/packages/@rescript/runtime/Belt_internalAVLtree.resi index fe1889a79f..432b987df8 100644 --- a/packages/@rescript/runtime/Belt_internalAVLtree.resi +++ b/packages/@rescript/runtime/Belt_internalAVLtree.resi @@ -92,7 +92,7 @@ let size: t<'a, 'b> => int let toList: t<'a, 'b> => list<('a, 'b)> /** -**raise** when invariant is not held +**throw** when invariant is not held */ let checkInvariantInternal: t<'a, 'b> => unit diff --git a/packages/@rescript/runtime/Js_float.res b/packages/@rescript/runtime/Js_float.res index dd72791c0b..19d81f0f8f 100644 --- a/packages/@rescript/runtime/Js_float.res +++ b/packages/@rescript/runtime/Js_float.res @@ -67,7 +67,7 @@ external isFinite: float => bool = "isFinite" /** Formats a `float` using exponential (scientific) notation. Return a -`string` representing the given value in exponential notation. Raise +`string` representing the given value in exponential notation. Throw RangeError if digits is not in the range \[0, 20\] (inclusive). See [`toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) on MDN. ## Examples @@ -88,7 +88,7 @@ Formats a `float` using exponential (scientific) notation. `digits` specifies how many digits should appear after the decimal point. The value must be in the range \[0, 20\] (inclusive). Return a `string` representing the given value in exponential notation. The output will be rounded or padded with zeroes if -necessary. Raise RangeError if `digits` is not in the range \[0, 20\] (inclusive). +necessary. Throw RangeError if `digits` is not in the range \[0, 20\] (inclusive). See [`toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) on MDN. ## Examples @@ -103,7 +103,7 @@ external toExponentialWithPrecision: (float, ~digits: int) => string = "toExpone /** Formats a `float` using fixed point notation. Return a `string` representing the -given value in fixed-point notation (usually). Raise RangeError if digits is not +given value in fixed-point notation (usually). Throw RangeError if digits is not in the range \[0, 20\] (inclusive). See [`toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed) on MDN. ## Examples @@ -127,7 +127,7 @@ fixed-point notation (usually). See [`toFixed`](https://developer.mozilla.org/en The output will be rounded or padded with zeroes if necessary. -Raise RangeError if digits is not in the range \[0, 20\] (inclusive) +Throw RangeError if digits is not in the range \[0, 20\] (inclusive) ## Examples @@ -149,7 +149,7 @@ from `Js.Float.toFixed` in that the former will format the number with full precision, while the latter will not output any digits after the decimal point. See [`toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN. -Raise RangeError if digits is not in the range accepted by this function (what do you mean "vague"?) +Throw RangeError if digits is not in the range accepted by this function (what do you mean "vague"?) ## Examples @@ -181,7 +181,7 @@ the digits after the decimal point. `toPrecisionWithPrecision` will also use scientific notation if the specified precision is less than the number for digits before the decimal point. -Raise RangeError if digits is not in the range accepted by this function (what do you mean "vague"?) +Throw RangeError if digits is not in the range accepted by this function (what do you mean "vague"?) ## Examples @@ -215,7 +215,7 @@ Formats a `float` as a string. `radix` specifies the radix base to use for the formatted number. The value must be in the range \[2, 36\] (inclusive). Return a `string` representing the given value in fixed-point (usually). See [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN. -Raise RangeError if radix is not in the range \[2, 36\] (inclusive) +Throw RangeError if radix is not in the range \[2, 36\] (inclusive) ## Examples diff --git a/packages/@rescript/runtime/Js_int.res b/packages/@rescript/runtime/Js_int.res index cf6cc7cf46..da4c40e306 100644 --- a/packages/@rescript/runtime/Js_int.res +++ b/packages/@rescript/runtime/Js_int.res @@ -38,7 +38,7 @@ comes with `NAN` /** Formats an `int` using exponential (scientific) notation. Returns a `string` representing the given value in exponential notation. -Raises `RangeError` if digits is not in the range \[0, 20\] (inclusive). +Throws `RangeError` if digits is not in the range \[0, 20\] (inclusive). See [`toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) on MDN. @@ -59,7 +59,7 @@ Formats an `int` using exponential (scientific) notation. Returns a `string` representing the given value in exponential notation. The output will be rounded or padded with zeroes if necessary. -Raises `RangeError` if `digits` is not in the range \[0, 20\] (inclusive). +Throws `RangeError` if `digits` is not in the range \[0, 20\] (inclusive). See [`toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) on MDN. @@ -81,7 +81,7 @@ Formats an `int` using some fairly arbitrary rules. Returns a `string` representing the given value in fixed-point (usually). `toPrecision` differs from `toFixed` in that the former will format the number with full precision, while the latter will not output any digits after the decimal point. -Raises `RangeError` if `digits` is not in the range accepted by this function. +Throws `RangeError` if `digits` is not in the range accepted by this function. See [`toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN. @@ -105,7 +105,7 @@ The output will be rounded or padded with zeroes if necessary. `toPrecisionWithPrecision` differs from `toFixedWithPrecision` in that the former will count all digits against the precision, while the latter will count only the digits after the decimal point. `toPrecisionWithPrecision` will also use scientific notation if the specified precision is less than the number of digits before the decimal point. -Raises `RangeError` if `digits` is not in the range accepted by this function. +Throws `RangeError` if `digits` is not in the range accepted by this function. See [`toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN. @@ -142,7 +142,7 @@ external toString: int => string = "toString" /** Formats an `int` as a `string`. `radix` specifies the radix base to use for the formatted number. The value must be in the range \[2, 36\] (inclusive). Returns -a `string` representing the given value in fixed-point (usually). Raises +a `string` representing the given value in fixed-point (usually). Throws `RangeError` if `radix` is not in the range \[2, 36\] (inclusive). diff --git a/packages/@rescript/runtime/Js_json.res b/packages/@rescript/runtime/Js_json.res index 49b672935e..381755ac3c 100644 --- a/packages/@rescript/runtime/Js_json.res +++ b/packages/@rescript/runtime/Js_json.res @@ -207,7 +207,7 @@ let serializeExn = (type t, x: t): string => }); if(output === undefined){ - // JSON.stringify will raise TypeError when it detects cylic objects + // JSON.stringify will throw TypeError when it detects cylic objects throw new TypeError("output is undefined") } return output diff --git a/packages/@rescript/runtime/Js_json.resi b/packages/@rescript/runtime/Js_json.resi index 4dce84f7ea..888757e7a5 100644 --- a/packages/@rescript/runtime/Js_json.resi +++ b/packages/@rescript/runtime/Js_json.resi @@ -149,7 +149,7 @@ external objectArray: array> => t = "%identity" /** `parseExn(s)` parses the `string` `s` into a JSON data structure. Returns a JSON data structure. -Raises `SyntaxError` if the given string is not a valid JSON. Note: `SyntaxError` is a JavaScript exception. +Throws `SyntaxError` if the given string is not a valid JSON. Note: `SyntaxError` is a JavaScript exception. See [`parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) on MDN. @@ -267,7 +267,7 @@ It is unsafe in two aspects let deserializeUnsafe: string => 'a /** -It will raise in such situations: +It will throw in such situations: - The object can not be serlialized to a JSON - There are cycles - Some JS engines can not stringify deeply nested json objects diff --git a/packages/@rescript/runtime/Js_math.res b/packages/@rescript/runtime/Js_math.res index dfda4e187c..1771a7671b 100644 --- a/packages/@rescript/runtime/Js_math.res +++ b/packages/@rescript/runtime/Js_math.res @@ -557,7 +557,7 @@ on MDN. external minMany_float: array => float = "min" /** -Raises the given base to the given exponent. (Arguments and result are +Throws the given base to the given exponent. (Arguments and result are integers.) See [`Math.pow`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow) on MDN. @@ -572,7 +572,7 @@ Js.Math.pow_int(~base=3, ~exp=4) == 81 external pow_int: (~base: int, ~exp: int) => int = "pow" /** -Raises the given base to the given exponent. (Arguments and result are +Throws the given base to the given exponent. (Arguments and result are floats.) Returns `NaN` if the result would be imaginary. See [`Math.pow`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow) on MDN. diff --git a/packages/@rescript/runtime/Js_string.res b/packages/@rescript/runtime/Js_string.res index a1df479520..65fe1c674f 100644 --- a/packages/@rescript/runtime/Js_string.res +++ b/packages/@rescript/runtime/Js_string.res @@ -68,9 +68,9 @@ external fromCharCodeMany: array => t = "String.fromCharCode" /** `fromCodePoint(n)` creates a `string` containing the character corresponding to -that numeric code point. If the number is not a valid code point, it raises +that numeric code point. If the number is not a valid code point, it throws `RangeError`.Thus, `fromCodePoint(0x1F63A)` will produce a correct value, -unlike `fromCharCode(0x1F63A)`, and `fromCodePoint(-5)` will raise a +unlike `fromCharCode(0x1F63A)`, and `fromCodePoint(-5)` will throw a `RangeError`. See [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint) @@ -481,7 +481,7 @@ let normalizeByForm = (arg1, obj) => normalizeByForm(obj, arg1) /** `repeat(n, str)` returns a `string` that consists of `n` repetitions of `str`. -Raises `RangeError` if `n` is negative. +Throws `RangeError` if `n` is negative. See [`String.repeat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat) on MDN. diff --git a/packages/@rescript/runtime/Js_string2.res b/packages/@rescript/runtime/Js_string2.res index 700b54a0c4..3485edd501 100644 --- a/packages/@rescript/runtime/Js_string2.res +++ b/packages/@rescript/runtime/Js_string2.res @@ -72,9 +72,9 @@ external fromCharCodeMany: array => t = "String.fromCharCode" /** `fromCodePoint(n)` creates a `string` containing the character corresponding to -that numeric code point. If the number is not a valid code point, it raises +that numeric code point. If the number is not a valid code point, it throws `RangeError`. Thus, `fromCodePoint(0x1F63A)` will produce a correct value, -unlike `fromCharCode(0x1F63A)`, and `fromCodePoint(-5)` will raise a +unlike `fromCharCode(0x1F63A)`, and `fromCodePoint(-5)` will throw a `RangeError`. See [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint) @@ -467,7 +467,7 @@ external normalizeByForm: (t, t) => t = "normalize" /** `repeat(str, n)` returns a `string` that consists of `n` repetitions of `str`. -Raises `RangeError` if `n` is negative. +Throws `RangeError` if `n` is negative. See [`String.repeat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat) on MDN. diff --git a/packages/@rescript/runtime/Js_typed_array.res b/packages/@rescript/runtime/Js_typed_array.res index 753c14fa72..0df3c01515 100644 --- a/packages/@rescript/runtime/Js_typed_array.res +++ b/packages/@rescript/runtime/Js_typed_array.res @@ -275,7 +275,7 @@ module Int8Array = { external fromBuffer: array_buffer => t = "Int8Array" /** - raise Js.Exn.Error raise Js exception + throw Js.Exn.Error throw Js exception param offset is in bytes */ @@ -283,7 +283,7 @@ module Int8Array = { external fromBufferOffset: (array_buffer, int) => t = "Int8Array" /** - raise Js.Exn.Error raises Js exception + throw Js.Exn.Error throws Js exception param offset is in bytes, length in elements */ @@ -399,7 +399,7 @@ module Uint8Array = { external fromBuffer: array_buffer => t = "Uint8Array" /** - **raise** Js.Exn.Error raise Js exception + **throw** Js.Exn.Error throw Js exception **param** offset is in bytes */ @@ -407,7 +407,7 @@ module Uint8Array = { external fromBufferOffset: (array_buffer, int) => t = "Uint8Array" /** - **raise** Js.Exn.Error raises Js exception + **throw** Js.Exn.Error throws Js exception **param** offset is in bytes, length in elements */ @@ -523,7 +523,7 @@ module Uint8ClampedArray = { external fromBuffer: array_buffer => t = "Uint8ClampedArray" /** - **raise** Js.Exn.Error raise Js exception + **throw** Js.Exn.Error throw Js exception **param** offset is in bytes */ @@ -531,7 +531,7 @@ module Uint8ClampedArray = { external fromBufferOffset: (array_buffer, int) => t = "Uint8ClampedArray" /** - **raise** Js.Exn.Error raises Js exception + **throw** Js.Exn.Error throws Js exception **param** offset is in bytes, length in elements */ @@ -647,7 +647,7 @@ module Int16Array = { external fromBuffer: array_buffer => t = "Int16Array" /** - **raise** Js.Exn.Error raise Js exception + **throw** Js.Exn.Error throw Js exception **param** offset is in bytes */ @@ -655,7 +655,7 @@ module Int16Array = { external fromBufferOffset: (array_buffer, int) => t = "Int16Array" /** - **raise** Js.Exn.Error raises Js exception + **throw** Js.Exn.Error throws Js exception **param** offset is in bytes, length in elements */ @@ -771,7 +771,7 @@ module Uint16Array = { external fromBuffer: array_buffer => t = "Uint16Array" /** - **raise** Js.Exn.Error raise Js exception + **throw** Js.Exn.Error throw Js exception **param** offset is in bytes */ @@ -779,7 +779,7 @@ module Uint16Array = { external fromBufferOffset: (array_buffer, int) => t = "Uint16Array" /** - **raise** Js.Exn.Error raises Js exception + **throw** Js.Exn.Error throws Js exception **param** offset is in bytes, length in elements */ @@ -895,7 +895,7 @@ module Int32Array = { external fromBuffer: array_buffer => t = "Int32Array" /** - **raise** Js.Exn.Error raise Js exception + **throw** Js.Exn.Error throw Js exception **param** offset is in bytes */ @@ -903,7 +903,7 @@ module Int32Array = { external fromBufferOffset: (array_buffer, int) => t = "Int32Array" /** - **raise** Js.Exn.Error raises Js exception + **throw** Js.Exn.Error throws Js exception **param** offset is in bytes, length in elements */ @@ -1022,7 +1022,7 @@ module Uint32Array = { external fromBuffer: array_buffer => t = "Uint32Array" /** - **raise** Js.Exn.Error raise Js exception + **throw** Js.Exn.Error throw Js exception **param** offset is in bytes */ @@ -1030,7 +1030,7 @@ module Uint32Array = { external fromBufferOffset: (array_buffer, int) => t = "Uint32Array" /** - **raise** Js.Exn.Error raises Js exception + **throw** Js.Exn.Error throws Js exception **param** offset is in bytes, length in elements */ @@ -1149,7 +1149,7 @@ module Float32Array = { external fromBuffer: array_buffer => t = "Float32Array" /** - **raise** Js.Exn.Error raise Js exception + **throw** Js.Exn.Error throw Js exception **param** offset is in bytes */ @@ -1157,7 +1157,7 @@ module Float32Array = { external fromBufferOffset: (array_buffer, int) => t = "Float32Array" /** - **raise** Js.Exn.Error raises Js exception + **throw** Js.Exn.Error throws Js exception **param** offset is in bytes, length in elements */ @@ -1277,7 +1277,7 @@ module Float64Array = { external fromBuffer: array_buffer => t = "Float64Array" /** - **raise** Js.Exn.Error raise Js exception + **throw** Js.Exn.Error throw Js exception **param** offset is in bytes */ @@ -1285,7 +1285,7 @@ module Float64Array = { external fromBufferOffset: (array_buffer, int) => t = "Float64Array" /** - **raise** Js.Exn.Error raises Js exception + **throw** Js.Exn.Error throws Js exception **param** offset is in bytes, length in elements */ diff --git a/packages/@rescript/runtime/Js_typed_array2.res b/packages/@rescript/runtime/Js_typed_array2.res index 873517c72f..a84623f725 100644 --- a/packages/@rescript/runtime/Js_typed_array2.res +++ b/packages/@rescript/runtime/Js_typed_array2.res @@ -165,7 +165,7 @@ module Int8Array = { external fromBuffer: array_buffer => t = "Int8Array" /** - **raise** Js.Exn.Error raise Js exception + **throw** Js.Exn.Error throw Js exception **param** offset is in bytes */ @@ -173,7 +173,7 @@ module Int8Array = { external fromBufferOffset: (array_buffer, int) => t = "Int8Array" /** - **raise** Js.Exn.Error raises Js exception + **throw** Js.Exn.Error throws Js exception **param** offset is in bytes, length in elements */ @@ -290,7 +290,7 @@ module Uint8Array = { external fromBuffer: array_buffer => t = "Uint8Array" /** - **raise** Js.Exn.Error raise Js exception + **throw** Js.Exn.Error throw Js exception **param** offset is in bytes */ @@ -298,7 +298,7 @@ module Uint8Array = { external fromBufferOffset: (array_buffer, int) => t = "Uint8Array" /** - **raise** Js.Exn.Error raises Js exception + **throw** Js.Exn.Error throws Js exception **param** offset is in bytes, length in elements */ @@ -415,7 +415,7 @@ module Uint8ClampedArray = { external fromBuffer: array_buffer => t = "Uint8ClampedArray" /** - **raise** Js.Exn.Error raise Js exception + **throw** Js.Exn.Error throw Js exception **param** offset is in bytes */ @@ -423,7 +423,7 @@ module Uint8ClampedArray = { external fromBufferOffset: (array_buffer, int) => t = "Uint8ClampedArray" /** - **raise** Js.Exn.Error raises Js exception + **throw** Js.Exn.Error throws Js exception **param** offset is in bytes, length in elements */ @@ -540,7 +540,7 @@ module Int16Array = { external fromBuffer: array_buffer => t = "Int16Array" /** - **raise** Js.Exn.Error raise Js exception + **throw** Js.Exn.Error throw Js exception **param** offset is in bytes */ @@ -548,7 +548,7 @@ module Int16Array = { external fromBufferOffset: (array_buffer, int) => t = "Int16Array" /** - **raise** Js.Exn.Error raises Js exception + **throw** Js.Exn.Error throws Js exception **param** offset is in bytes, length in elements */ @@ -665,7 +665,7 @@ module Uint16Array = { external fromBuffer: array_buffer => t = "Uint16Array" /** - **raise** Js.Exn.Error raise Js exception + **throw** Js.Exn.Error throw Js exception **param** offset is in bytes */ @@ -673,7 +673,7 @@ module Uint16Array = { external fromBufferOffset: (array_buffer, int) => t = "Uint16Array" /** - **raise** Js.Exn.Error raises Js exception + **throw** Js.Exn.Error throws Js exception **param** offset is in bytes, length in elements */ @@ -790,7 +790,7 @@ module Int32Array = { external fromBuffer: array_buffer => t = "Int32Array" /** - **raise** Js.Exn.Error raise Js exception + **throw** Js.Exn.Error throw Js exception **param** offset is in bytes */ @@ -798,7 +798,7 @@ module Int32Array = { external fromBufferOffset: (array_buffer, int) => t = "Int32Array" /** - **raise** Js.Exn.Error raises Js exception + **throw** Js.Exn.Error throws Js exception **param** offset is in bytes, length in elements */ @@ -915,7 +915,7 @@ module Uint32Array = { external fromBuffer: array_buffer => t = "Uint32Array" /** - **raise** Js.Exn.Error raise Js exception + **throw** Js.Exn.Error throw Js exception **param** offset is in bytes */ @@ -923,7 +923,7 @@ module Uint32Array = { external fromBufferOffset: (array_buffer, int) => t = "Uint32Array" /** - **raise** Js.Exn.Error raises Js exception + **throw** Js.Exn.Error throws Js exception **param** offset is in bytes, length in elements */ @@ -1043,7 +1043,7 @@ module Float32Array = { external fromBuffer: array_buffer => t = "Float32Array" /** - **raise** Js.Exn.Error raise Js exception + **throw** Js.Exn.Error throw Js exception **param** offset is in bytes */ @@ -1051,7 +1051,7 @@ module Float32Array = { external fromBufferOffset: (array_buffer, int) => t = "Float32Array" /** - **raise** Js.Exn.Error raises Js exception + **throw** Js.Exn.Error throws Js exception **param** offset is in bytes, length in elements */ @@ -1168,7 +1168,7 @@ module Float64Array = { external fromBuffer: array_buffer => t = "Float64Array" /** - **raise** Js.Exn.Error raise Js exception + **throw** Js.Exn.Error throw Js exception **param** offset is in bytes */ @@ -1176,7 +1176,7 @@ module Float64Array = { external fromBufferOffset: (array_buffer, int) => t = "Float64Array" /** - **raise** Js.Exn.Error raises Js exception + **throw** Js.Exn.Error throws Js exception **param** offset is in bytes, length in elements */ diff --git a/packages/@rescript/runtime/Primitive_object.res b/packages/@rescript/runtime/Primitive_object.res index 1cd4f44658..4c70770acf 100644 --- a/packages/@rescript/runtime/Primitive_object.res +++ b/packages/@rescript/runtime/Primitive_object.res @@ -67,7 +67,7 @@ let updateDummy = Primitive_object_extern.updateDummy Namely, the comparison predicates treat nan as different from any other float value, including itself; while compare treats [nan] as equal to itself and less than any other float value. This treatment of [nan] ensures that compare defines a total ordering relation. - compare applied to functional values may raise Invalid_argument. compare applied to cyclic structures + compare applied to functional values may throw Invalid_argument. compare applied to cyclic structures may not terminate. The compare function can be used as the comparison function required by the [Set.Make] and [Map.Make] functors, @@ -268,7 +268,7 @@ let rec equal = (a: t, b: t): bool => ) { false } else { - /* [a] [b] could not be null, so it can not raise */ + /* [a] [b] could not be null, so it can not throw */ let tag_a = tag(a) let tag_b = tag(b) if tag_a != tag_b { diff --git a/packages/@rescript/runtime/Stdlib.res b/packages/@rescript/runtime/Stdlib.res index f0e44ff0b5..285aedc656 100644 --- a/packages/@rescript/runtime/Stdlib.res +++ b/packages/@rescript/runtime/Stdlib.res @@ -109,7 +109,7 @@ external import: 'a => promise<'a> = "%import" let panic = JsError.panic /** -`assertEqual(a, b)` check if `a` is equal `b`. If not raise a panic exception +`assertEqual(a, b)` check if `a` is equal `b`. If not throw a panic exception ## Examples diff --git a/packages/@rescript/runtime/Stdlib_Error.resi b/packages/@rescript/runtime/Stdlib_Error.resi index ad7f05b367..40467129e2 100644 --- a/packages/@rescript/runtime/Stdlib_Error.resi +++ b/packages/@rescript/runtime/Stdlib_Error.resi @@ -164,7 +164,7 @@ if 5 > 10 { external raise: t => 'a = "%raise" /** -Raises the given exception, terminating execution unless caught by a surrounding try/catch block. +Throws the given exception, terminating execution unless caught by a surrounding try/catch block. ## Examples @@ -182,7 +182,7 @@ if 5 > 10 { external throw: t => 'a = "%raise" /** -Raises a panic exception with the given message. +Throws a panic exception with the given message. A panic exception is a native JavaScript exception that is not intended to be caught and handled. Compared to a ReScript exception this will give a better stack trace and diff --git a/packages/@rescript/runtime/Stdlib_Int.resi b/packages/@rescript/runtime/Stdlib_Int.resi index 384e351287..edee442ec0 100644 --- a/packages/@rescript/runtime/Stdlib_Int.resi +++ b/packages/@rescript/runtime/Stdlib_Int.resi @@ -321,7 +321,7 @@ If `step` is set, the sequence will increase or decrease by that amount for each step. If `start < end` and `step` is negative, or vice versa, an empty array is returned since the sequence would otherwise never reach or exceed the end value and hence be infinite. If `step` is `0` and `start !=` end, a `RangeError` is -raised as the sequence would never reach or exceed the end value and hence be +thrown as the sequence would never reach or exceed the end value and hence be infinite. If `inclusive` is set to `true`, the sequence will include `end` if `step` is diff --git a/packages/@rescript/runtime/Stdlib_JSON.resi b/packages/@rescript/runtime/Stdlib_JSON.resi index 5133d4cac4..a69b4f4fc1 100644 --- a/packages/@rescript/runtime/Stdlib_JSON.resi +++ b/packages/@rescript/runtime/Stdlib_JSON.resi @@ -58,7 +58,7 @@ try { ## Exceptions -- Raises a SyntaxError (Exn.t) if the string isn't valid JSON. +- Throws a SyntaxError (Exn.t) if the string isn't valid JSON. */ @throws(Exn.t) @val external parseOrThrow: (string, ~reviver: (string, t) => t=?) => t = "JSON.parse" @@ -104,7 +104,7 @@ try { ## Exceptions -- Raises a SyntaxError (Exn.t) if the string isn't valid JSON. +- Throws a SyntaxError (Exn.t) if the string isn't valid JSON. */ @deprecated("Use `parseOrThrow` instead") @throws(Exn.t) @val external parseExn: (string, ~reviver: (string, t) => t=?) => t = "JSON.parse" @@ -140,7 +140,7 @@ try { ## Exceptions -- Raises a SyntaxError if the string is not a valid JSON. +- Throws a SyntaxError if the string is not a valid JSON. */ @deprecated("Use `parseOrThrow` with optional parameter instead") @throws(Exn.t) @val external parseExnWithReviver: (string, (string, t) => t) => t = "JSON.parse" @@ -387,7 +387,7 @@ dict JSON.stringifyAny(() => "hello world") == None -// Raise a exception +// Throw a exception switch BigInt.fromInt(0)->JSON.stringifyAny { | exception _ => assert(true) | _ => assert(false) @@ -396,8 +396,8 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { ## Exceptions -- Raises a TypeError if the value contains circular references. -- Raises a TypeError if the value contains `BigInt`s. +- Throws a TypeError if the value contains circular references. +- Throws a TypeError if the value contains `BigInt`s. */ @throws(Exn.t) @val external stringifyAny: ('a, ~replacer: replacer=?, ~space: int=?) => option = @@ -438,8 +438,8 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { ## Exceptions -- Raises a TypeError if the value contains circular references. -- Raises a TypeError if the value contains `BigInt`s. +- Throws a TypeError if the value contains circular references. +- Throws a TypeError if the value contains `BigInt`s. */ @deprecated("Use `stringifyAny` with optional parameter instead") @throws(Exn.t) @val external stringifyAnyWithIndent: ('a, @as(json`null`) _, int) => option = "JSON.stringify" @@ -484,8 +484,8 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { ## Exceptions -- Raises a TypeError if the value contains circular references. -- Raises a TypeError if the value contains `BigInt`s. +- Throws a TypeError if the value contains circular references. +- Throws a TypeError if the value contains `BigInt`s. */ @deprecated("Use `stringifyAny` with optional parameter instead") @throws @val external stringifyAnyWithReplacer: ('a, (string, t) => t) => option = "JSON.stringify" @@ -531,8 +531,8 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { ## Exceptions -- Raises a TypeError if the value contains circular references. -- Raises a TypeError if the value contains `BigInt`s. +- Throws a TypeError if the value contains circular references. +- Throws a TypeError if the value contains `BigInt`s. */ @deprecated("Use `stringifyAny` with optional parameters instead") @throws @val external stringifyAnyWithReplacerAndIndent: ('a, (string, t) => t, int) => option = @@ -568,8 +568,8 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { ## Exceptions -- Raises a TypeError if the value contains circular references. -- Raises a TypeError if the value contains `BigInt`s. +- Throws a TypeError if the value contains circular references. +- Throws a TypeError if the value contains `BigInt`s. */ @deprecated("Use `stringifyAny` with optional parameter instead") @throws @val external stringifyAnyWithFilter: ('a, array) => string = "JSON.stringify" @@ -618,8 +618,8 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { ## Exceptions -- Raises a TypeError if the value contains circular references. -- Raises a TypeError if the value contains `BigInt`s. +- Throws a TypeError if the value contains circular references. +- Throws a TypeError if the value contains `BigInt`s. */ @deprecated("Use `stringifyAny` with optional parameters instead") @throws @val external stringifyAnyWithFilterAndIndent: ('a, array, int) => string = "JSON.stringify" diff --git a/packages/@rescript/runtime/Stdlib_Lazy.resi b/packages/@rescript/runtime/Stdlib_Lazy.resi index 624a39441c..e4e733412a 100644 --- a/packages/@rescript/runtime/Stdlib_Lazy.resi +++ b/packages/@rescript/runtime/Stdlib_Lazy.resi @@ -9,8 +9,8 @@ The type of a lazy value. `Lazy.t<'a>` represents a lazy value that will eventually yield a value of type `'a` when accessed. The value is computed only once, and the result is cached for - subsequent accesses. If the computation raises an exception, - the same exception is raised again on subsequent accesses. + subsequent accesses. If the computation throws an exception, + the same exception is thrown again on subsequent accesses. */ @notUndefined type t<+'a> @@ -36,16 +36,16 @@ let make: (unit => 'a) => t<'a> /** `Lazy.get(x)` forces the suspension `x` and returns its result. If `x` has already been forced, `Lazy.get(x)` returns the - same value again without recomputing it. If it raised an - exception, the same exception is raised again. - Raise `Undefined` if the forcing of `x` tries to force `x` itself + same value again without recomputing it. If it threw an + exception, the same exception is thrown again. + Throw `Undefined` if the forcing of `x` tries to force `x` itself recursively. This is a runtime error. */ let get: t<'a> => 'a /** `Lazy.isEvaluated(x)` returns `true` if the suspension `x` has - already been forced and did not raise an exception. Otherwise, + already been forced and did not throw an exception. Otherwise, it returns `false`. This is useful for checking if a lazy value has been computed before accessing it. @@ -68,9 +68,9 @@ exception Undefined /** `force(x)` forces the suspension `x` and returns its result. If `x` has already been forced, `Lazy.force(x)` returns the - same value again without recomputing it. If it raised an exception, - the same exception is raised again. - Raise `Undefined` if the forcing of `x` tries to force `x` itself + same value again without recomputing it. If it threw an exception, + the same exception is thrown again. + Throw `Undefined` if the forcing of `x` tries to force `x` itself recursively. */ @deprecated("Use `Lazy.get` instead") @@ -80,10 +80,10 @@ let force: t<'a> => 'a `force_val(x)` forces the suspension `x` and returns its result. If `x` has already been forced, `force_val(x)` returns the same value again without recomputing it. - Raise `Undefined` if the forcing of `x` tries to force `x` itself + Throw `Undefined` if the forcing of `x` tries to force `x` itself recursively. - If the computation of `x` raises an exception, it is unspecified - whether `force_val(x)` raises the same exception or `Undefined`. + If the computation of `x` throws an exception, it is unspecified + whether `force_val(x)` throws the same exception or `Undefined`. */ @deprecated("Use `Lazy.get` instead") let force_val: t<'a> => 'a @@ -106,7 +106,7 @@ let from_val: 'a => t<'a> /** `is_val(x)` returns `true` if `x has already been forced and - did not raise an exception. + did not throw an exception. */ @deprecated("Use `Lazy.isEvaluated` instead") let is_val: t<'a> => bool diff --git a/packages/@rescript/runtime/Stdlib_List.resi b/packages/@rescript/runtime/Stdlib_List.resi index 86c9a0615b..b275d5f6f4 100644 --- a/packages/@rescript/runtime/Stdlib_List.resi +++ b/packages/@rescript/runtime/Stdlib_List.resi @@ -87,7 +87,7 @@ switch List.headExn(list{}) { ## Exceptions -- Raises an Error if list is empty. +- Throws an Error if list is empty. */ @deprecated("Use `headOrThrow` instead") @@ -109,7 +109,7 @@ switch List.headOrThrow(list{}) { ## Exceptions -- Raises an Error if list is empty. +- Throws an Error if list is empty. */ let headOrThrow: list<'a> => 'a @@ -143,7 +143,7 @@ switch List.tailExn(list{}) { ## Exceptions -- Raises an Error if list is empty. +- Throws an Error if list is empty. */ @deprecated("Use `tailOrThrow` instead") let tailExn: list<'a> => list<'a> @@ -164,7 +164,7 @@ switch List.tailOrThrow(list{}) { ## Exceptions -- Raises an Error if list is empty. +- Throws an Error if list is empty. */ let tailOrThrow: list<'a> => list<'a> @@ -215,7 +215,7 @@ switch abc->List.getExn(4) { ## Exceptions -- Raises an Error if `index` is larger than the length of list. +- Throws an Error if `index` is larger than the length of list. */ @deprecated("Use `getOrThrow` instead") let getExn: (list<'a>, int) => 'a @@ -238,7 +238,7 @@ switch abc->List.getOrThrow(4) { ## Exceptions -- Raises an Error if `index` is larger than the length of list. +- Throws an Error if `index` is larger than the length of list. */ let getOrThrow: (list<'a>, int) => 'a diff --git a/packages/@rescript/runtime/Stdlib_Math.resi b/packages/@rescript/runtime/Stdlib_Math.resi index 322dd87156..fc6b6f5e9a 100644 --- a/packages/@rescript/runtime/Stdlib_Math.resi +++ b/packages/@rescript/runtime/Stdlib_Math.resi @@ -246,7 +246,7 @@ See [`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referen external maxMany: array => int = "Math.max" /** - `pow(a, ~exp)` raises the given base `a` to the given exponent `exp`. + `pow(a, ~exp)` throws the given base `a` to the given exponent `exp`. See [`Math.pow`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow) on MDN. ## Examples @@ -729,7 +729,7 @@ Math.maxMany([])->Float.isFinite == false external maxMany: array => float = "Math.max" /** -`pow(a, ~exp)` raises the given base `a` to the given exponent `exp`. +`pow(a, ~exp)` throws the given base `a` to the given exponent `exp`. See [`Math.pow`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow) on MDN. ## Examples diff --git a/packages/@rescript/runtime/Stdlib_Null.resi b/packages/@rescript/runtime/Stdlib_Null.resi index 464c14e131..73fa022485 100644 --- a/packages/@rescript/runtime/Stdlib_Null.resi +++ b/packages/@rescript/runtime/Stdlib_Null.resi @@ -136,7 +136,7 @@ let getOr: (t<'a>, 'a) => 'a let getWithDefault: (t<'a>, 'a) => 'a /** -`getExn(value)` raises an exception if `null`, otherwise returns the value. +`getExn(value)` throws an exception if `null`, otherwise returns the value. ```rescript Null.getExn(Null.make(3)) == 3 @@ -154,13 +154,13 @@ switch Null.getExn(%raw("null")) { ## Exceptions -- Raises `Invalid_argument` if `value` is `null` +- Throws `Invalid_argument` if `value` is `null` */ @deprecated("Use `getOrThrow` instead") let getExn: t<'a> => 'a /** -`getOrThrow(value)` raises an exception if `null`, otherwise returns the value. +`getOrThrow(value)` throws an exception if `null`, otherwise returns the value. ```rescript Null.getOrThrow(Null.make(3)) == 3 @@ -178,7 +178,7 @@ switch Null.getOrThrow(%raw("null")) { ## Exceptions -- Raises `Invalid_argument` if `value` is `null` +- Throws `Invalid_argument` if `value` is `null` */ let getOrThrow: t<'a> => 'a @@ -189,7 +189,7 @@ let getOrThrow: t<'a> => 'a ```rescript Null.getUnsafe(Null.make(3)) == 3 -Null.getUnsafe(Null.null) // Raises an error +Null.getUnsafe(Null.null) // Throws an error ``` ## Important diff --git a/packages/@rescript/runtime/Stdlib_Nullable.resi b/packages/@rescript/runtime/Stdlib_Nullable.resi index a46f954707..dee061906a 100644 --- a/packages/@rescript/runtime/Stdlib_Nullable.resi +++ b/packages/@rescript/runtime/Stdlib_Nullable.resi @@ -133,7 +133,7 @@ let getOr: (t<'a>, 'a) => 'a let getWithDefault: (t<'a>, 'a) => 'a /** -`getExn(value)` raises an exception if `null` or `undefined`, otherwise returns the value. +`getExn(value)` throws an exception if `null` or `undefined`, otherwise returns the value. ```rescript switch Nullable.getExn(%raw("'Hello'")) { @@ -154,13 +154,13 @@ switch Nullable.getExn(%raw("undefined")) { ## Exceptions -- Raises `Invalid_argument` if `value` is `null` or `undefined` +- Throws `Invalid_argument` if `value` is `null` or `undefined` */ @deprecated("Use `getOrThrow` instead") let getExn: t<'a> => 'a /** -`getOrThrow(value)` raises an exception if `null` or `undefined`, otherwise returns the value. +`getOrThrow(value)` throws an exception if `null` or `undefined`, otherwise returns the value. ```rescript switch Nullable.getOrThrow(%raw("'Hello'")) { @@ -181,7 +181,7 @@ switch Nullable.getOrThrow(%raw("undefined")) { ## Exceptions -- Raises `Invalid_argument` if `value` is `null` or `undefined` +- Throws `Invalid_argument` if `value` is `null` or `undefined` */ let getOrThrow: t<'a> => 'a @@ -192,7 +192,7 @@ let getOrThrow: t<'a> => 'a ```rescript Nullable.getUnsafe(Nullable.make(3)) == 3 -Nullable.getUnsafe(Nullable.null) // Raises an error +Nullable.getUnsafe(Nullable.null) // Throws an error ``` ## Important diff --git a/packages/@rescript/runtime/Stdlib_Promise.resi b/packages/@rescript/runtime/Stdlib_Promise.resi index 626ae5f70c..a502a5ddda 100644 --- a/packages/@rescript/runtime/Stdlib_Promise.resi +++ b/packages/@rescript/runtime/Stdlib_Promise.resi @@ -429,7 +429,7 @@ external allSettled6: ((t<'a>, t<'b>, t<'c>, t<'d>, t<'e>, t<'f>)) => t<( /** `done(p)` is a safe way to ignore a promise. If a value is anything else than a -promise, it will raise a type error. +promise, it will throw a type error. */ @deprecated("Please use `Promise.ignore` instead") external done: promise<'a> => unit = "%ignore" diff --git a/packages/@rescript/runtime/cppo/belt_Set.resi.cppo b/packages/@rescript/runtime/cppo/belt_Set.resi.cppo index d390940a13..7765a32daf 100644 --- a/packages/@rescript/runtime/cppo/belt_Set.resi.cppo +++ b/packages/@rescript/runtime/cppo/belt_Set.resi.cppo @@ -170,6 +170,6 @@ element equal to `x`, or `true` if `s` contains an element equal to `x`. let split: (t, value) => ((t, t), bool) /** -**raise** when invariant is not held +**throw** when invariant is not held */ let checkInvariantInternal: t => unit diff --git a/packages/@rescript/runtime/cppo/map.resi.cppo b/packages/@rescript/runtime/cppo/map.resi.cppo index 8bc4d81eba..f339f2b724 100644 --- a/packages/@rescript/runtime/cppo/map.resi.cppo +++ b/packages/@rescript/runtime/cppo/map.resi.cppo @@ -133,7 +133,7 @@ let getWithDefault: (t<'v>, key, 'v) => 'v let getExn: (t<'v>, key) => 'v /** -**raise** when invariant is not held +**throw** when invariant is not held */ let checkInvariantInternal: t<_> => unit diff --git a/packages/@rescript/runtime/cppo/mapm.resi.cppo b/packages/@rescript/runtime/cppo/mapm.resi.cppo index 37f831a116..7046a3ddfb 100644 --- a/packages/@rescript/runtime/cppo/mapm.resi.cppo +++ b/packages/@rescript/runtime/cppo/mapm.resi.cppo @@ -114,7 +114,7 @@ let getWithDefault: (t<'a>, key, 'a) => 'a let getExn: (t<'a>, key) => 'a /** - **raise** when invariant is not held + **throw** when invariant is not held */ let checkInvariantInternal: t<_> => unit diff --git a/packages/@rescript/runtime/cppo/setm.resi.cppo b/packages/@rescript/runtime/cppo/setm.resi.cppo index bbfe9a538b..8e9611b880 100644 --- a/packages/@rescript/runtime/cppo/setm.resi.cppo +++ b/packages/@rescript/runtime/cppo/setm.resi.cppo @@ -139,6 +139,6 @@ let getExn: (t, value) => value let split: (t, value) => ((t, t), bool) /** -**raise** when invariant is not held +**throw** when invariant is not held */ let checkInvariantInternal: t => unit diff --git a/packages/@rescript/runtime/lib/es6/Js_json.js b/packages/@rescript/runtime/lib/es6/Js_json.js index 8b78627746..100c7be78d 100644 --- a/packages/@rescript/runtime/lib/es6/Js_json.js +++ b/packages/@rescript/runtime/lib/es6/Js_json.js @@ -140,7 +140,7 @@ function serializeExn(x) { }); if(output === undefined){ - // JSON.stringify will raise TypeError when it detects cylic objects + // JSON.stringify will throw TypeError when it detects cylic objects throw new TypeError("output is undefined") } return output diff --git a/packages/@rescript/runtime/lib/js/Js_json.js b/packages/@rescript/runtime/lib/js/Js_json.js index d4d0ee4f35..d074c4cfb6 100644 --- a/packages/@rescript/runtime/lib/js/Js_json.js +++ b/packages/@rescript/runtime/lib/js/Js_json.js @@ -140,7 +140,7 @@ function serializeExn(x) { }); if(output === undefined){ - // JSON.stringify will raise TypeError when it detects cylic objects + // JSON.stringify will throw TypeError when it detects cylic objects throw new TypeError("output is undefined") } return output From 09d44ee99112db565d0f2223e1765d7bddde0572 Mon Sep 17 00:00:00 2001 From: tsnobip Date: Fri, 3 Oct 2025 09:27:48 +0200 Subject: [PATCH 09/10] remove unused @throws annotations --- packages/@rescript/runtime/Stdlib_JSON.resi | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/@rescript/runtime/Stdlib_JSON.resi b/packages/@rescript/runtime/Stdlib_JSON.resi index a69b4f4fc1..7ad1b60a20 100644 --- a/packages/@rescript/runtime/Stdlib_JSON.resi +++ b/packages/@rescript/runtime/Stdlib_JSON.resi @@ -60,7 +60,7 @@ try { - Throws a SyntaxError (Exn.t) if the string isn't valid JSON. */ -@throws(Exn.t) @val +@val external parseOrThrow: (string, ~reviver: (string, t) => t=?) => t = "JSON.parse" /** @@ -106,7 +106,7 @@ try { - Throws a SyntaxError (Exn.t) if the string isn't valid JSON. */ -@deprecated("Use `parseOrThrow` instead") @throws(Exn.t) @val +@deprecated("Use `parseOrThrow` instead") @val external parseExn: (string, ~reviver: (string, t) => t=?) => t = "JSON.parse" /** @@ -142,7 +142,7 @@ try { - Throws a SyntaxError if the string is not a valid JSON. */ -@deprecated("Use `parseOrThrow` with optional parameter instead") @throws(Exn.t) @val +@deprecated("Use `parseOrThrow` with optional parameter instead") @val external parseExnWithReviver: (string, (string, t) => t) => t = "JSON.parse" /** @@ -399,7 +399,7 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { - Throws a TypeError if the value contains circular references. - Throws a TypeError if the value contains `BigInt`s. */ -@throws(Exn.t) @val +@val external stringifyAny: ('a, ~replacer: replacer=?, ~space: int=?) => option = "JSON.stringify" @@ -441,7 +441,7 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { - Throws a TypeError if the value contains circular references. - Throws a TypeError if the value contains `BigInt`s. */ -@deprecated("Use `stringifyAny` with optional parameter instead") @throws(Exn.t) @val +@deprecated("Use `stringifyAny` with optional parameter instead") @val external stringifyAnyWithIndent: ('a, @as(json`null`) _, int) => option = "JSON.stringify" /** @@ -487,7 +487,7 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { - Throws a TypeError if the value contains circular references. - Throws a TypeError if the value contains `BigInt`s. */ -@deprecated("Use `stringifyAny` with optional parameter instead") @throws @val +@deprecated("Use `stringifyAny` with optional parameter instead") @val external stringifyAnyWithReplacer: ('a, (string, t) => t) => option = "JSON.stringify" /** @@ -534,7 +534,7 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { - Throws a TypeError if the value contains circular references. - Throws a TypeError if the value contains `BigInt`s. */ -@deprecated("Use `stringifyAny` with optional parameters instead") @throws @val +@deprecated("Use `stringifyAny` with optional parameters instead") @val external stringifyAnyWithReplacerAndIndent: ('a, (string, t) => t, int) => option = "JSON.stringify" @@ -571,7 +571,7 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { - Throws a TypeError if the value contains circular references. - Throws a TypeError if the value contains `BigInt`s. */ -@deprecated("Use `stringifyAny` with optional parameter instead") @throws @val +@deprecated("Use `stringifyAny` with optional parameter instead") @val external stringifyAnyWithFilter: ('a, array) => string = "JSON.stringify" /** @@ -621,7 +621,7 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { - Throws a TypeError if the value contains circular references. - Throws a TypeError if the value contains `BigInt`s. */ -@deprecated("Use `stringifyAny` with optional parameters instead") @throws @val +@deprecated("Use `stringifyAny` with optional parameters instead") @val external stringifyAnyWithFilterAndIndent: ('a, array, int) => string = "JSON.stringify" module Classify: { From 501eaa2dd6b52aca433129614d12ff05e068d5dc Mon Sep 17 00:00:00 2001 From: tsnobip Date: Fri, 3 Oct 2025 09:50:34 +0200 Subject: [PATCH 10/10] update completion --- .../tests-reanalyze/deadcode/expected/exception.txt | 6 +++--- .../tests/src/expected/CompletionExpressions.res.txt | 2 +- .../tests/src/expected/CompletionJsx.res.txt | 4 ++-- .../src/expected/CompletionNullNullable.res.txt | 12 ++++++------ 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/expected/exception.txt b/tests/analysis_tests/tests-reanalyze/deadcode/expected/exception.txt index 04132a8472..0ebfeb0072 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/expected/exception.txt +++ b/tests/analysis_tests/tests-reanalyze/deadcode/expected/exception.txt @@ -14,7 +14,7 @@ Exception Analysis Exn.res:22:5-42 - callsThrowWithAnnotationAndIsAnnotated might raise Not_found (Exn.res:22:45) and is annotated with redundant @throws(A) + callsThrowWithAnnotationAndIsAnnotated might throw Not_found (Exn.res:22:45) and is annotated with redundant @throws(A) Exception Analysis Exn.res:24:5-19 @@ -38,7 +38,7 @@ Exception Analysis Exn.res:62:5-19 - throw2Annotate3 might raise [A (Exn.res:64:4), B (Exn.res:67:4)] and is annotated with redundant @throws(C) + throw2Annotate3 might throw [A (Exn.res:64:4), B (Exn.res:67:4)] and is annotated with redundant @throws(C) Exception Analysis Exn.res:73:5-24 @@ -62,7 +62,7 @@ Exception Analysis Exn.res:133:5-23 - redundantAnnotation raises nothing and is annotated with redundant @throws(Invalid_argument) + redundantAnnotation throws nothing and is annotated with redundant @throws(Invalid_argument) Exception Analysis Exn.res:135:5-6 diff --git a/tests/analysis_tests/tests/src/expected/CompletionExpressions.res.txt b/tests/analysis_tests/tests/src/expected/CompletionExpressions.res.txt index 680b29abeb..31c667898b 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionExpressions.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionExpressions.res.txt @@ -832,7 +832,7 @@ Path fnTakingCallback "kind": 12, "tags": [], "detail": "('a, 'a) => unit", - "documentation": {"kind": "markdown", "value": "\n`assertEqual(a, b)` check if `a` is equal `b`. If not raise a panic exception\n\n## Examples\n\n```rescript\nlist{1, 2}->List.tailExn == list{2}\n```\n"} + "documentation": {"kind": "markdown", "value": "\n`assertEqual(a, b)` check if `a` is equal `b`. If not throw a panic exception\n\n## Examples\n\n```rescript\nlist{1, 2}->List.tailExn == list{2}\n```\n"} }] Complete src/CompletionExpressions.res 165:22 diff --git a/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt b/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt index cd4f01377d..88ae80dd76 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt @@ -285,7 +285,7 @@ Path "kind": 12, "tags": [], "detail": "(int, int, ~options: rangeOptions=?) => array", - "documentation": {"kind": "markdown", "value": "\n`range(start, end, ~options=?)` returns an int array of the sequence of integers in the\nrange `[start, end)`. That is, including `start` but excluding `end`.\n\nIf `step` is not set and `start < end`, the sequence will be increasing in steps of 1.\n\nIf `step` is not set and `start > end`, the sequence will be decreasing in steps of -1.\n\nIf `step` is set, the sequence will increase or decrease by that amount for each\nstep. If `start < end` and `step` is negative, or vice versa, an empty array is\nreturned since the sequence would otherwise never reach or exceed the end value\nand hence be infinite. If `step` is `0` and `start !=` end, a `RangeError` is\nraised as the sequence would never reach or exceed the end value and hence be\ninfinite.\n\nIf `inclusive` is set to `true`, the sequence will include `end` if `step` is\nset such that the sequence includes it.\n\n## Examples\n\n```rescript\nInt.range(3, 6) == [3, 4, 5]\nInt.range(-3, -1) == [-3, -2]\nInt.range(3, 1) == [3, 2]\nInt.range(3, 7, ~options={step: 2}) == [3, 5]\nInt.range(3, 7, ~options={step: 2, inclusive: true}) == [3, 5, 7]\nInt.range(3, 6, ~options={step: -2}) // RangeError\n```\n\n## Exceptions\n\n- Raises `RangeError` if `step == 0 && start != end`.\n"} + "documentation": {"kind": "markdown", "value": "\n`range(start, end, ~options=?)` returns an int array of the sequence of integers in the\nrange `[start, end)`. That is, including `start` but excluding `end`.\n\nIf `step` is not set and `start < end`, the sequence will be increasing in steps of 1.\n\nIf `step` is not set and `start > end`, the sequence will be decreasing in steps of -1.\n\nIf `step` is set, the sequence will increase or decrease by that amount for each\nstep. If `start < end` and `step` is negative, or vice versa, an empty array is\nreturned since the sequence would otherwise never reach or exceed the end value\nand hence be infinite. If `step` is `0` and `start !=` end, a `RangeError` is\nthrown as the sequence would never reach or exceed the end value and hence be\ninfinite.\n\nIf `inclusive` is set to `true`, the sequence will include `end` if `step` is\nset such that the sequence includes it.\n\n## Examples\n\n```rescript\nInt.range(3, 6) == [3, 4, 5]\nInt.range(-3, -1) == [-3, -2]\nInt.range(3, 1) == [3, 2]\nInt.range(3, 7, ~options={step: 2}) == [3, 5]\nInt.range(3, 7, ~options={step: 2, inclusive: true}) == [3, 5, 7]\nInt.range(3, 6, ~options={step: -2}) // RangeError\n```\n\n## Exceptions\n\n- Raises `RangeError` if `step == 0 && start != end`.\n"} }, { "label": "Int.toString", "kind": 12, @@ -455,7 +455,7 @@ Path "kind": 12, "tags": [], "detail": "(int, int, ~options: rangeOptions=?) => array", - "documentation": {"kind": "markdown", "value": "\n`range(start, end, ~options=?)` returns an int array of the sequence of integers in the\nrange `[start, end)`. That is, including `start` but excluding `end`.\n\nIf `step` is not set and `start < end`, the sequence will be increasing in steps of 1.\n\nIf `step` is not set and `start > end`, the sequence will be decreasing in steps of -1.\n\nIf `step` is set, the sequence will increase or decrease by that amount for each\nstep. If `start < end` and `step` is negative, or vice versa, an empty array is\nreturned since the sequence would otherwise never reach or exceed the end value\nand hence be infinite. If `step` is `0` and `start !=` end, a `RangeError` is\nraised as the sequence would never reach or exceed the end value and hence be\ninfinite.\n\nIf `inclusive` is set to `true`, the sequence will include `end` if `step` is\nset such that the sequence includes it.\n\n## Examples\n\n```rescript\nInt.range(3, 6) == [3, 4, 5]\nInt.range(-3, -1) == [-3, -2]\nInt.range(3, 1) == [3, 2]\nInt.range(3, 7, ~options={step: 2}) == [3, 5]\nInt.range(3, 7, ~options={step: 2, inclusive: true}) == [3, 5, 7]\nInt.range(3, 6, ~options={step: -2}) // RangeError\n```\n\n## Exceptions\n\n- Raises `RangeError` if `step == 0 && start != end`.\n"} + "documentation": {"kind": "markdown", "value": "\n`range(start, end, ~options=?)` returns an int array of the sequence of integers in the\nrange `[start, end)`. That is, including `start` but excluding `end`.\n\nIf `step` is not set and `start < end`, the sequence will be increasing in steps of 1.\n\nIf `step` is not set and `start > end`, the sequence will be decreasing in steps of -1.\n\nIf `step` is set, the sequence will increase or decrease by that amount for each\nstep. If `start < end` and `step` is negative, or vice versa, an empty array is\nreturned since the sequence would otherwise never reach or exceed the end value\nand hence be infinite. If `step` is `0` and `start !=` end, a `RangeError` is\nthrown as the sequence would never reach or exceed the end value and hence be\ninfinite.\n\nIf `inclusive` is set to `true`, the sequence will include `end` if `step` is\nset such that the sequence includes it.\n\n## Examples\n\n```rescript\nInt.range(3, 6) == [3, 4, 5]\nInt.range(-3, -1) == [-3, -2]\nInt.range(3, 1) == [3, 2]\nInt.range(3, 7, ~options={step: 2}) == [3, 5]\nInt.range(3, 7, ~options={step: 2, inclusive: true}) == [3, 5, 7]\nInt.range(3, 6, ~options={step: -2}) // RangeError\n```\n\n## Exceptions\n\n- Raises `RangeError` if `step == 0 && start != end`.\n"} }, { "label": "Int.toString", "kind": 12, diff --git a/tests/analysis_tests/tests/src/expected/CompletionNullNullable.res.txt b/tests/analysis_tests/tests/src/expected/CompletionNullNullable.res.txt index 470774fe18..8903a5ef5a 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionNullNullable.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionNullNullable.res.txt @@ -29,7 +29,7 @@ Path "kind": 12, "tags": [], "detail": "t<'a> => 'a", - "documentation": {"kind": "markdown", "value": "\n`getUnsafe(value)` returns `value`.\n\n## Examples\n\n```rescript\nNull.getUnsafe(Null.make(3)) == 3\nNull.getUnsafe(Null.null) // Raises an error\n```\n\n## Important\n\n- This is an unsafe operation, it assumes `value` is not `null`.\n"}, + "documentation": {"kind": "markdown", "value": "\n`getUnsafe(value)` returns `value`.\n\n## Examples\n\n```rescript\nNull.getUnsafe(Null.make(3)) == 3\nNull.getUnsafe(Null.null) // Throws an error\n```\n\n## Important\n\n- This is an unsafe operation, it assumes `value` is not `null`.\n"}, "sortText": "getUnsafe", "insertText": "->Null.getUnsafe", "additionalTextEdits": [{ @@ -53,7 +53,7 @@ Path "kind": 12, "tags": [1], "detail": "t<'a> => 'a", - "documentation": {"kind": "markdown", "value": "Deprecated: Use `getOrThrow` instead\n\n\n`getExn(value)` raises an exception if `null`, otherwise returns the value.\n\n```rescript\nNull.getExn(Null.make(3)) == 3\n\nswitch Null.getExn(%raw(\"'ReScript'\")) {\n| exception Invalid_argument(_) => assert(false)\n| value => value == \"ReScript\"\n}\n\nswitch Null.getExn(%raw(\"null\")) {\n| exception Invalid_argument(_) => assert(true)\n| _ => assert(false)\n}\n```\n\n## Exceptions\n\n- Raises `Invalid_argument` if `value` is `null`\n"}, + "documentation": {"kind": "markdown", "value": "Deprecated: Use `getOrThrow` instead\n\n\n`getExn(value)` throws an exception if `null`, otherwise returns the value.\n\n```rescript\nNull.getExn(Null.make(3)) == 3\n\nswitch Null.getExn(%raw(\"'ReScript'\")) {\n| exception Invalid_argument(_) => assert(false)\n| value => value == \"ReScript\"\n}\n\nswitch Null.getExn(%raw(\"null\")) {\n| exception Invalid_argument(_) => assert(true)\n| _ => assert(false)\n}\n```\n\n## Exceptions\n\n- Throws `Invalid_argument` if `value` is `null`\n"}, "sortText": "getExn", "insertText": "->Null.getExn", "additionalTextEdits": [{ @@ -89,7 +89,7 @@ Path "kind": 12, "tags": [], "detail": "t<'a> => 'a", - "documentation": {"kind": "markdown", "value": "\n`getOrThrow(value)` raises an exception if `null`, otherwise returns the value.\n\n```rescript\nNull.getOrThrow(Null.make(3)) == 3\n\nswitch Null.getOrThrow(%raw(\"'ReScript'\")) {\n| exception Invalid_argument(_) => assert(false)\n| value => value == \"ReScript\"\n}\n\nswitch Null.getOrThrow(%raw(\"null\")) {\n| exception Invalid_argument(_) => assert(true)\n| _ => assert(false)\n}\n```\n\n## Exceptions\n\n- Raises `Invalid_argument` if `value` is `null`\n"}, + "documentation": {"kind": "markdown", "value": "\n`getOrThrow(value)` throws an exception if `null`, otherwise returns the value.\n\n```rescript\nNull.getOrThrow(Null.make(3)) == 3\n\nswitch Null.getOrThrow(%raw(\"'ReScript'\")) {\n| exception Invalid_argument(_) => assert(false)\n| value => value == \"ReScript\"\n}\n\nswitch Null.getOrThrow(%raw(\"null\")) {\n| exception Invalid_argument(_) => assert(true)\n| _ => assert(false)\n}\n```\n\n## Exceptions\n\n- Throws `Invalid_argument` if `value` is `null`\n"}, "sortText": "getOrThrow", "insertText": "->Null.getOrThrow", "additionalTextEdits": [{ @@ -225,7 +225,7 @@ Path "kind": 12, "tags": [], "detail": "t<'a> => 'a", - "documentation": {"kind": "markdown", "value": "\n`getUnsafe(value)` returns `value`.\n\n## Examples\n\n```rescript\nNullable.getUnsafe(Nullable.make(3)) == 3\nNullable.getUnsafe(Nullable.null) // Raises an error\n```\n\n## Important\n\n- This is an unsafe operation, it assumes `value` is not `null` or `undefined`.\n"}, + "documentation": {"kind": "markdown", "value": "\n`getUnsafe(value)` returns `value`.\n\n## Examples\n\n```rescript\nNullable.getUnsafe(Nullable.make(3)) == 3\nNullable.getUnsafe(Nullable.null) // Throws an error\n```\n\n## Important\n\n- This is an unsafe operation, it assumes `value` is not `null` or `undefined`.\n"}, "sortText": "getUnsafe", "insertText": "->Nullable.getUnsafe", "additionalTextEdits": [{ @@ -249,7 +249,7 @@ Path "kind": 12, "tags": [1], "detail": "t<'a> => 'a", - "documentation": {"kind": "markdown", "value": "Deprecated: Use `getOrThrow` instead\n\n\n`getExn(value)` raises an exception if `null` or `undefined`, otherwise returns the value.\n\n```rescript\nswitch Nullable.getExn(%raw(\"'Hello'\")) {\n| exception Invalid_argument(_) => assert(false)\n| value => value == \"Hello\"\n}\n\nswitch Nullable.getExn(%raw(\"null\")) {\n| exception Invalid_argument(_) => assert(true)\n| _ => assert(false)\n}\n\nswitch Nullable.getExn(%raw(\"undefined\")) {\n| exception Invalid_argument(_) => assert(true)\n| _ => assert(false)\n}\n```\n\n## Exceptions\n\n- Raises `Invalid_argument` if `value` is `null` or `undefined`\n"}, + "documentation": {"kind": "markdown", "value": "Deprecated: Use `getOrThrow` instead\n\n\n`getExn(value)` throws an exception if `null` or `undefined`, otherwise returns the value.\n\n```rescript\nswitch Nullable.getExn(%raw(\"'Hello'\")) {\n| exception Invalid_argument(_) => assert(false)\n| value => value == \"Hello\"\n}\n\nswitch Nullable.getExn(%raw(\"null\")) {\n| exception Invalid_argument(_) => assert(true)\n| _ => assert(false)\n}\n\nswitch Nullable.getExn(%raw(\"undefined\")) {\n| exception Invalid_argument(_) => assert(true)\n| _ => assert(false)\n}\n```\n\n## Exceptions\n\n- Throws `Invalid_argument` if `value` is `null` or `undefined`\n"}, "sortText": "getExn", "insertText": "->Nullable.getExn", "additionalTextEdits": [{ @@ -285,7 +285,7 @@ Path "kind": 12, "tags": [], "detail": "t<'a> => 'a", - "documentation": {"kind": "markdown", "value": "\n`getOrThrow(value)` raises an exception if `null` or `undefined`, otherwise returns the value.\n\n```rescript\nswitch Nullable.getOrThrow(%raw(\"'Hello'\")) {\n| exception Invalid_argument(_) => assert(false)\n| value => value == \"Hello\"\n}\n\nswitch Nullable.getOrThrow(%raw(\"null\")) {\n| exception Invalid_argument(_) => assert(true)\n| _ => assert(false)\n}\n\nswitch Nullable.getOrThrow(%raw(\"undefined\")) {\n| exception Invalid_argument(_) => assert(true)\n| _ => assert(false)\n}\n```\n\n## Exceptions\n\n- Raises `Invalid_argument` if `value` is `null` or `undefined`\n"}, + "documentation": {"kind": "markdown", "value": "\n`getOrThrow(value)` throws an exception if `null` or `undefined`, otherwise returns the value.\n\n```rescript\nswitch Nullable.getOrThrow(%raw(\"'Hello'\")) {\n| exception Invalid_argument(_) => assert(false)\n| value => value == \"Hello\"\n}\n\nswitch Nullable.getOrThrow(%raw(\"null\")) {\n| exception Invalid_argument(_) => assert(true)\n| _ => assert(false)\n}\n\nswitch Nullable.getOrThrow(%raw(\"undefined\")) {\n| exception Invalid_argument(_) => assert(true)\n| _ => assert(false)\n}\n```\n\n## Exceptions\n\n- Throws `Invalid_argument` if `value` is `null` or `undefined`\n"}, "sortText": "getOrThrow", "insertText": "->Nullable.getOrThrow", "additionalTextEdits": [{