diff --git a/CHANGELOG.md b/CHANGELOG.md index b6088034e6..dc5710f5be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ #### :bug: Bug fix - `rescript-tools doc` no longer includes shadowed bindings in its output. https://github.com/rescript-lang/rescript/pull/7497 +- Treat `throw` like `raise` in analysis. https://github.com/rescript-lang/rescript/pull/7521 #### :nail_care: Polish diff --git a/analysis/examples/larger-project/src/arg_helper.res b/analysis/examples/larger-project/src/arg_helper.res index 898906c6d4..19958bb15b 100644 --- a/analysis/examples/larger-project/src/arg_helper.res +++ b/analysis/examples/larger-project/src/arg_helper.res @@ -76,19 +76,19 @@ module Make = ( | exception Not_found => switch S.Value.of_string(value) { | value => set_user_default(value, acc) - | exception exn => raise(Parse_failure(exn)) + | exception exn => throw(Parse_failure(exn)) } | equals => let key_value_pair = value let length = String.length(key_value_pair) assert (equals >= 0 && equals < length) if equals == 0 { - raise(Parse_failure(Failure("Missing key in argument specification"))) + throw(Parse_failure(Failure("Missing key in argument specification"))) } let key = { let key = String.sub(key_value_pair, 0, equals) try S.Key.of_string(key) catch { - | exn => raise(Parse_failure(exn)) + | exn => throw(Parse_failure(exn)) } } @@ -96,7 +96,7 @@ module Make = ( let value = String.sub(key_value_pair, equals + 1, length - equals - 1) try S.Value.of_string(value) catch { - | exn => raise(Parse_failure(exn)) + | exn => throw(Parse_failure(exn)) } } diff --git a/analysis/examples/larger-project/src/ast_helper.res b/analysis/examples/larger-project/src/ast_helper.res index fa5c7cb594..3cbe7a0f24 100644 --- a/analysis/examples/larger-project/src/ast_helper.res +++ b/analysis/examples/larger-project/src/ast_helper.res @@ -47,7 +47,7 @@ let with_default_loc = (l, f) => { } catch { | exn => default_loc := old - raise(exn) + throw(exn) } } @@ -94,7 +94,7 @@ module Typ = { @raises(Error) let check_variable = (vl, loc, v) => if List.mem(v, vl) { - raise({ + throw({ open Syntaxerr Error(Variable_in_scope(loc, v)) }) diff --git a/analysis/examples/larger-project/src/exception/BsJson.res b/analysis/examples/larger-project/src/exception/BsJson.res index ad892c8e7b..f56a2aee1d 100644 --- a/analysis/examples/larger-project/src/exception/BsJson.res +++ b/analysis/examples/larger-project/src/exception/BsJson.res @@ -1,5 +1,5 @@ -@raise(DecodeError) +@throw(DecodeError) let testBsJson = x => Json_decode.string(x) -@raise(DecodeError) +@throw(DecodeError) let testBsJson2 = x => Json.Decode.string(x) diff --git a/analysis/examples/larger-project/src/exception/ExnB.res b/analysis/examples/larger-project/src/exception/ExnB.res index 2a50ef4652..3749dfd029 100644 --- a/analysis/examples/larger-project/src/exception/ExnB.res +++ b/analysis/examples/larger-project/src/exception/ExnB.res @@ -1,2 +1,2 @@ @raises(Not_found) -let foo = () => raise(Not_found) +let foo = () => throw(Not_found) diff --git a/analysis/examples/larger-project/src/exception/Yojson.res b/analysis/examples/larger-project/src/exception/Yojson.res index 40758bda19..ec0f9c72f1 100644 --- a/analysis/examples/larger-project/src/exception/Yojson.res +++ b/analysis/examples/larger-project/src/exception/Yojson.res @@ -4,13 +4,13 @@ module Basic = { type t @raises(Json_error) - let from_string: string => t = _ => raise(Json_error("Basic.from_string")) + let from_string: string => t = _ => throw(Json_error("Basic.from_string")) module Util = { exception Type_error(string, t) @raises(Type_error) - let member: (string, t) => t = (_s, j) => raise(Type_error("Basic.Util.member", j)) + let member: (string, t) => t = (_s, j) => throw(Type_error("Basic.Util.member", j)) let to_int: t => int = _ => 34 diff --git a/analysis/examples/larger-project/src/location.res b/analysis/examples/larger-project/src/location.res index 332f0c40d6..6909c78809 100644 --- a/analysis/examples/larger-project/src/location.res +++ b/analysis/examples/larger-project/src/location.res @@ -257,5 +257,5 @@ let () = register_error_of_exn(x => @raises(Error) let raise_errorf = (~loc=none, ~sub=list{}, ~if_highlight="") => pp_ksprintf(~before=print_phanton_error_prefix, msg => - raise(Error({loc: loc, msg: msg, sub: sub, if_highlight: if_highlight})) + throw(Error({loc: loc, msg: msg, sub: sub, if_highlight: if_highlight})) ) diff --git a/analysis/examples/larger-project/src/misc.res b/analysis/examples/larger-project/src/misc.res index ff95a24c65..5872e8ae4e 100644 --- a/analysis/examples/larger-project/src/misc.res +++ b/analysis/examples/larger-project/src/misc.res @@ -23,7 +23,7 @@ exception Fatal_error let fatal_error = msg => { print_string(">> Fatal error: ") prerr_endline(msg) - raise(Fatal_error) + throw(Fatal_error) } @raises(Fatal_error) @@ -36,7 +36,7 @@ let try_finally = (work, cleanup) => { let result = try work() catch { | e => cleanup() - raise(e) + throw(e) } cleanup() result @@ -56,7 +56,7 @@ let protect_refs = { x | exception e => set_refs(backup) - raise(e) + throw(e) } } } @@ -149,7 +149,7 @@ module Stdlib = { let rec aux = (acc, l1, l2) => switch (l1, l2) { | (list{}, _) => (List.rev(acc), l2) - | (list{_, ..._}, list{}) => raise(Invalid_argument("map2_prefix")) + | (list{_, ..._}, list{}) => throw(Invalid_argument("map2_prefix")) | (list{h1, ...t1}, list{h2, ...t2}) => let h = f(h1, h2) aux(list{h, ...acc}, t1, t2) @@ -179,7 +179,7 @@ module Stdlib = { (List.rev(acc), l) } else { switch l { - | list{} => raise(Invalid_argument("split_at")) + | list{} => throw(Invalid_argument("split_at")) | list{t, ...q} => aux(n - 1, list{t, ...acc}, q) } } @@ -254,13 +254,13 @@ let find_in_path = (path, name) => if Sys.file_exists(name) { name } else { - raise(Not_found) + throw(Not_found) } } else { @raises(Not_found) let rec try_dir = x => switch x { - | list{} => raise(Not_found) + | list{} => throw(Not_found) | list{dir, ...rem} => let fullname = Filename.concat(dir, name) if Sys.file_exists(fullname) { @@ -290,7 +290,7 @@ let find_in_path_rel = (path, name) => { @raises(Not_found) let rec try_dir = x => switch x { - | list{} => raise(Not_found) + | list{} => throw(Not_found) | list{dir, ...rem} => let fullname = simplify(Filename.concat(dir, name)) if Sys.file_exists(fullname) { @@ -309,7 +309,7 @@ let find_in_path_uncap = (path, name) => { @raises(Not_found) let rec try_dir = x => switch x { - | list{} => raise(Not_found) + | list{} => throw(Not_found) | list{dir, ...rem} => let fullname = Filename.concat(dir, name) and ufullname = Filename.concat(dir, uname) @@ -381,7 +381,7 @@ let copy_file_chunk = (ic, oc, len) => { } else { let r = input(ic, buff, 0, min(n, 0x1000)) if r == 0 { - raise(End_of_file) + throw(End_of_file) } else { output(oc, buff, 0, r) copy(n - r) @@ -435,12 +435,12 @@ let output_to_file_via_temporary = (~mode=list{Open_text}, filename, fn) => { } catch { | exn => remove_file(temp_filename) - raise(exn) + throw(exn) } | exception exn => close_out(oc) remove_file(temp_filename) - raise(exn) + throw(exn) } } @@ -514,7 +514,7 @@ let search_substring = (pat, str, start) => { if j >= String.length(pat) { i } else if i + j >= String.length(str) { - raise(Not_found) + throw(Not_found) } else if String.get(str, i + j) == String.get(pat, j) { search(i, j + 1) } else { @@ -831,7 +831,7 @@ module Color = { | "error" => cur_styles.contents.error | "warning" => cur_styles.contents.warning | "loc" => cur_styles.contents.loc - | _ => raise(Not_found) + | _ => throw(Not_found) } let color_enabled = ref(true) @@ -957,15 +957,15 @@ exception HookExnWrapper({error: exn, hook_name: string, hook_info: hook_info}) exception HookExn(exn) @raises(HookExn) -let raise_direct_hook_exn = e => raise(HookExn(e)) +let raise_direct_hook_exn = e => throw(HookExn(e)) @raises([HookExnWrapper, genericException]) let fold_hooks = (list, hook_info, ast) => List.fold_left( (ast, (hook_name, f)) => try f(hook_info, ast) catch { - | HookExn(e) => raise(e) - | error => raise(HookExnWrapper({error: error, hook_name: hook_name, hook_info: hook_info})) + | HookExn(e) => throw(e) + | error => throw(HookExnWrapper({error: error, hook_name: hook_name, hook_info: hook_info})) }, /* when explicit reraise with backtrace will be available, it should be used here */ diff --git a/analysis/examples/larger-project/src/res_token.res b/analysis/examples/larger-project/src/res_token.res index 8528ea46f2..88944ce7df 100644 --- a/analysis/examples/larger-project/src/res_token.res +++ b/analysis/examples/larger-project/src/res_token.res @@ -249,7 +249,7 @@ let keywordTable = x => | "type" => Typ | "when" => When | "while" => While - | _ => raise(Not_found) + | _ => throw(Not_found) } let isKeyword = x => diff --git a/analysis/examples/larger-project/src/syntaxerr.res b/analysis/examples/larger-project/src/syntaxerr.res index 4d5e0426c8..ae3d6bdb74 100644 --- a/analysis/examples/larger-project/src/syntaxerr.res +++ b/analysis/examples/larger-project/src/syntaxerr.res @@ -86,5 +86,5 @@ let location_of_error = x => | Expecting(l, _) => l } -let ill_formed_ast = (loc, s) => raise(Error(Ill_formed_ast(loc, s))) +let ill_formed_ast = (loc, s) => throw(Error(Ill_formed_ast(loc, s))) diff --git a/analysis/examples/larger-project/src/warnings.res b/analysis/examples/larger-project/src/warnings.res index 12664097e4..94bfa3c7dc 100644 --- a/analysis/examples/larger-project/src/warnings.res +++ b/analysis/examples/larger-project/src/warnings.res @@ -237,7 +237,7 @@ let mk_lazy = f => { } catch { | exn => restore(prev) - raise(exn) + throw(exn) } } } @@ -249,7 +249,7 @@ let parse_opt = (error, active, flags, s) => { active[i] = true error[i] = true } - let error = () => raise(Arg.Bad("Ill-formed list of warnings")) + let error = () => throw(Arg.Bad("Ill-formed list of warnings")) let rec get_num = (n, i) => if i >= String.length(s) { (i, n) @@ -601,7 +601,7 @@ let reset_fatal = () => nerrors := 0 let check_fatal = () => if nerrors.contents > 0 { nerrors := 0 - raise(Errors) + throw(Errors) } let descriptions = list{ diff --git a/analysis/reanalyze/src/Exception.ml b/analysis/reanalyze/src/Exception.ml index d9a5c59dbd..d59516e2dd 100644 --- a/analysis/reanalyze/src/Exception.ml +++ b/analysis/reanalyze/src/Exception.ml @@ -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.raise_notrace" in + let isRaise s = s = "Pervasives.raise" || s = "Pervasives.throw" in let raiseArgs args = match args with | [(_, Some {Typedtree.exp_desc = Texp_construct ({txt}, _, _)})] -> 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 79fd0f55f9..89341b7fea 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res @@ -1,4 +1,4 @@ -let raises = () => raise(Not_found) +let raises = () => throw(Not_found) let catches1 = try () catch { | Not_found => () @@ -9,12 +9,12 @@ let catches2 = switch () { | exception Not_found => () } -let raiseAndCatch = try raise(Not_found) catch { +let raiseAndCatch = try throw(Not_found) catch { | _ => () } @raises(Not_found) -let raisesWithAnnotaion = () => raise(Not_found) +let raisesWithAnnotaion = () => throw(Not_found) let callsRaiseWithAnnotation = raisesWithAnnotaion() @@ -31,28 +31,28 @@ exception B let twoRaises = (x, y) => { if x { - raise(A) + throw(A) } if y { - raise(B) + throw(B) } } let sequencing = () => { - raise(A) - try raise(B) catch { + throw(A) + try throw(B) catch { | _ => () } } let wrongCatch = () => - try raise(B) catch { + try throw(B) catch { | A => () } exception C let wrongCatch2 = b => - switch b ? raise(B) : raise(C) { + switch b ? throw(B) : throw(C) { | exception A => () | exception B => () | list{} => () @@ -61,10 +61,10 @@ let wrongCatch2 = b => @raises([A, B, C]) let raise2Annotate3 = (x, y) => { if x { - raise(A) + throw(A) } if y { - raise(B) + throw(B) } } @@ -72,24 +72,24 @@ exception Error(string, string, int) let parse_json_from_file = s => { switch 34 { - | exception Error(p1, p2, e) => raise(Error(p1, p2, e)) + | exception Error(p1, p2, e) => throw(Error(p1, p2, e)) | v => v } } let reRaise = () => - switch raise(A) { - | exception A => raise(B) + switch throw(A) { + | exception A => throw(B) | _ => 11 } -let switchWithCatchAll = switch raise(A) { +let switchWithCatchAll = switch throw(A) { | exception _ => 1 | _ => 2 } let raiseInInternalLet = b => { - let a = b ? raise(A) : 22 + let a = b ? throw(A) : 22 a + 34 } @@ -110,7 +110,7 @@ let tryChar = v => { let raiseAtAt = () => \"@@"(raise, Not_found) @raises(Not_found) -let raisePipe = raise(Not_found) +let raisePipe = throw(Not_found) @raises(Not_found) let raiseArrow = Not_found->raise @@ -127,18 +127,18 @@ let severalCases = cases => } @raises(genericException) -let genericRaiseIsNotSupported = exn => raise(exn) +let genericRaiseIsNotSupported = exn => throw(exn) @raises(Invalid_argument) let redundantAnnotation = () => () -let _x = raise(A) +let _x = throw(A) -let _ = raise(A) +let _ = throw(A) -let () = raise(A) +let () = throw(A) -raise(Not_found) +throw(Not_found) // Examples with pipe 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 2a50ef4652..3749dfd029 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) -let foo = () => raise(Not_found) +let foo = () => throw(Not_found) 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 40758bda19..ec0f9c72f1 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Yojson.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Yojson.res @@ -4,13 +4,13 @@ module Basic = { type t @raises(Json_error) - let from_string: string => t = _ => raise(Json_error("Basic.from_string")) + let from_string: string => t = _ => throw(Json_error("Basic.from_string")) module Util = { exception Type_error(string, t) @raises(Type_error) - let member: (string, t) => t = (_s, j) => raise(Type_error("Basic.Util.member", j)) + let member: (string, t) => t = (_s, j) => throw(Type_error("Basic.Util.member", j)) let to_int: t => int = _ => 34 diff --git a/tests/analysis_tests/tests-reanalyze/termination/src/TestCyberTruck.res b/tests/analysis_tests/tests-reanalyze/termination/src/TestCyberTruck.res index 0ec2e9b863..e2c6be68c7 100644 --- a/tests/analysis_tests/tests-reanalyze/termination/src/TestCyberTruck.res +++ b/tests/analysis_tests/tests-reanalyze/termination/src/TestCyberTruck.res @@ -438,7 +438,7 @@ module TerminationTypes = { @progress(progress) let rec testTry = () => { - try raise(Not_found) catch { + try throw(Not_found) catch { | Not_found => let _ = #abc(progress()) testTry() diff --git a/tests/analysis_tests/tests/src/Completion.res b/tests/analysis_tests/tests/src/Completion.res index ea683cfafe..9d8c870769 100644 --- a/tests/analysis_tests/tests/src/Completion.res +++ b/tests/analysis_tests/tests/src/Completion.res @@ -143,7 +143,7 @@ let foo = { let v = 44 } exception MyException(int, string, float, array) - let _ = raise(MyException(2, "", 1.0, [])) + let _ = throw(MyException(2, "", 1.0, [])) add((x: Inner.z), Inner.v + y) } diff --git a/tests/syntax_benchmarks/data/Napkinscript.res b/tests/syntax_benchmarks/data/Napkinscript.res index 710590ed3a..80429ca4de 100644 --- a/tests/syntax_benchmarks/data/Napkinscript.res +++ b/tests/syntax_benchmarks/data/Napkinscript.res @@ -1832,7 +1832,7 @@ module Token = { | "catch" => Catch | "import" => Import | "export" => Export - | _ => raise(Not_found) + | _ => throw(Not_found) } let isKeyword = x => diff --git a/tests/syntax_tests/data/idempotency/bs-css/Css.res b/tests/syntax_tests/data/idempotency/bs-css/Css.res index 492b63b0e1..ddf09a8ef5 100644 --- a/tests/syntax_tests/data/idempotency/bs-css/Css.res +++ b/tests/syntax_tests/data/idempotency/bs-css/Css.res @@ -4,11 +4,11 @@ include Css_Colors include Css_Legacy_Core.Make({ exception NotImplemented - let make = (. _) => raise(NotImplemented) - let mergeStyles = (. _) => raise(NotImplemented) + let make = (. _) => throw(NotImplemented) + let mergeStyles = (. _) => throw(NotImplemented) let injectRule = (. _) => () let injectRaw = (. _) => () - let makeKeyFrames = (. _) => raise(NotImplemented) + let makeKeyFrames = (. _) => throw(NotImplemented) }) external unsafeJsonToStyles: Js.Json.t => ReactDOMRe.Style.t = "%identity" diff --git a/tests/syntax_tests/data/idempotency/bs-css/CssJs.res b/tests/syntax_tests/data/idempotency/bs-css/CssJs.res index ad8caf19cd..eaaa61690d 100644 --- a/tests/syntax_tests/data/idempotency/bs-css/CssJs.res +++ b/tests/syntax_tests/data/idempotency/bs-css/CssJs.res @@ -4,11 +4,11 @@ include Css_Colors include Css_Js_Core.Make({ exception NotImplemented - let make = (. _) => raise(NotImplemented) - let mergeStyles = (. _) => raise(NotImplemented) + let make = (. _) => throw(NotImplemented) + let mergeStyles = (. _) => throw(NotImplemented) let injectRule = (. _) => () let injectRaw = (. _) => () - let makeKeyFrames = (. _) => raise(NotImplemented) + let makeKeyFrames = (. _) => throw(NotImplemented) }) external unsafeJsonToStyles: Js.Json.t => ReactDOMRe.Style.t = "%identity" diff --git a/tests/syntax_tests/data/idempotency/bs-css/Css_test.res b/tests/syntax_tests/data/idempotency/bs-css/Css_test.res index d0b3074109..b1a211e6a6 100644 --- a/tests/syntax_tests/data/idempotency/bs-css/Css_test.res +++ b/tests/syntax_tests/data/idempotency/bs-css/Css_test.res @@ -4,11 +4,11 @@ module CssForTest = { include Css_Legacy_Core.Make({ exception NotImplemented - let mergeStyles = (. _) => raise(NotImplemented) - let make = (. _) => raise(NotImplemented) - let injectRule = (. _) => raise(NotImplemented) - let injectRaw = (. _) => raise(NotImplemented) - let makeKeyFrames = (. _) => raise(NotImplemented) + let mergeStyles = (. _) => throw(NotImplemented) + let make = (. _) => throw(NotImplemented) + let injectRule = (. _) => throw(NotImplemented) + let injectRaw = (. _) => throw(NotImplemented) + let makeKeyFrames = (. _) => throw(NotImplemented) }) } diff --git a/tests/syntax_tests/data/idempotency/bs-css/Selectors_test.res b/tests/syntax_tests/data/idempotency/bs-css/Selectors_test.res index ba74f6fa0a..36aa2e3e31 100644 --- a/tests/syntax_tests/data/idempotency/bs-css/Selectors_test.res +++ b/tests/syntax_tests/data/idempotency/bs-css/Selectors_test.res @@ -3,11 +3,11 @@ module CssForTest = { include Css_Legacy_Core.Make({ exception NotImplemented - let mergeStyles = (. _) => raise(NotImplemented) - let make = (. _) => raise(NotImplemented) - let injectRule = (. _) => raise(NotImplemented) - let injectRaw = (. _) => raise(NotImplemented) - let makeKeyFrames = (. _) => raise(NotImplemented) + let mergeStyles = (. _) => throw(NotImplemented) + let make = (. _) => throw(NotImplemented) + let injectRule = (. _) => throw(NotImplemented) + let injectRaw = (. _) => throw(NotImplemented) + let makeKeyFrames = (. _) => throw(NotImplemented) }) } diff --git a/tests/syntax_tests/data/idempotency/bs-css/Svg_test.res b/tests/syntax_tests/data/idempotency/bs-css/Svg_test.res index 6a199948eb..235defa949 100644 --- a/tests/syntax_tests/data/idempotency/bs-css/Svg_test.res +++ b/tests/syntax_tests/data/idempotency/bs-css/Svg_test.res @@ -3,11 +3,11 @@ module CssForTest = { include Css_Legacy_Core.Make({ exception NotImplemented - let mergeStyles = (. _) => raise(NotImplemented) - let make = (. _) => raise(NotImplemented) - let injectRule = (. _) => raise(NotImplemented) - let injectRaw = (. _) => raise(NotImplemented) - let makeKeyFrames = (. _) => raise(NotImplemented) + let mergeStyles = (. _) => throw(NotImplemented) + let make = (. _) => throw(NotImplemented) + let injectRule = (. _) => throw(NotImplemented) + let injectRaw = (. _) => throw(NotImplemented) + let makeKeyFrames = (. _) => throw(NotImplemented) }) } diff --git a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Canvas/Webapi__Canvas__Canvas2d.res b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Canvas/Webapi__Canvas__Canvas2d.res index 22f3fd3181..17b0eec391 100644 --- a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Canvas/Webapi__Canvas__Canvas2d.res +++ b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Canvas/Webapi__Canvas__Canvas2d.res @@ -128,7 +128,7 @@ let reifyStyle = (type a, x: 'a): (style, a) => { } else if Internal.instanceOf(x, Internal.canvasPattern) { Obj.magic(Pattern) } else { - raise( + throw( Invalid_argument( "Unknown canvas style kind. Known values are: String, CanvasGradient, CanvasPattern", ), diff --git a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Types.res b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Types.res index 7300187b39..04ff48d834 100644 --- a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Types.res +++ b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Types.res @@ -77,7 +77,7 @@ let decodeDeltaMode = x => | 0 => Pixel | 1 => Line | 2 => Page - | _ => raise(Invalid_argument("invalid deltaMode")) + | _ => throw(Invalid_argument("invalid deltaMode")) } type designMode = @@ -273,7 +273,7 @@ let decodeShadowRootMode = x => switch x { | "open" => Open | "closed" => Closed - | _ => raise(Invalid_argument("Unknown shadowRootMode")) + | _ => throw(Invalid_argument("Unknown shadowRootMode")) } type visibilityState = diff --git a/tests/syntax_tests/data/idempotency/bs-webapi/tests/testHelpers.res b/tests/syntax_tests/data/idempotency/bs-webapi/tests/testHelpers.res index e8704e6d57..2b129a7524 100644 --- a/tests/syntax_tests/data/idempotency/bs-webapi/tests/testHelpers.res +++ b/tests/syntax_tests/data/idempotency/bs-webapi/tests/testHelpers.res @@ -1,5 +1,5 @@ let unsafelyUnwrapOption = x => switch x { | Some(v) => v - | None => raise(Invalid_argument("Passed `None` to unsafelyUnwrapOption")) + | None => throw(Invalid_argument("Passed `None` to unsafelyUnwrapOption")) } diff --git a/tests/syntax_tests/data/idempotency/genType/src/Arnold.res b/tests/syntax_tests/data/idempotency/genType/src/Arnold.res index 4a11f21c94..74fc821f68 100644 --- a/tests/syntax_tests/data/idempotency/genType/src/Arnold.res +++ b/tests/syntax_tests/data/idempotency/genType/src/Arnold.res @@ -822,7 +822,7 @@ module Compile = { ) { | None => Stats.logHygieneMustHaveNamedArgument(~label, ~loc) - raise(ArgError) + throw(ArgError) | Some((path, _pos)) if path->FunctionTable.isInFunctionInTable(~functionTable) => let functionName = Path.name(path) @@ -840,7 +840,7 @@ module Compile = { | _ => Stats.logHygieneNamedArgValue(~label, ~loc) - raise(ArgError) + throw(ArgError) } functionArg } diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/App.res b/tests/syntax_tests/data/idempotency/nook-exchange/App.res index f3731fbe28..24c6b99ca5 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/App.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/App.res @@ -139,7 +139,7 @@ let make = () => { localStorage->getItem("discord_state") } != Some(state) ) { - raise(DiscordOauthStateMismatch(state)) + throw(DiscordOauthStateMismatch(state)) } DiscordOauth.process( ~code, diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/Experiment.res b/tests/syntax_tests/data/idempotency/nook-exchange/Experiment.res index 1df6698e2f..6a4f41a2c3 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/Experiment.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/Experiment.res @@ -51,7 +51,7 @@ let getBucketIdForExperiment = (~experimentId) => } else if experimentId == ExperimentIds.quicklistOverlay { string_of_int(land(lsr(getBucketHash(), 3), 1)) } else { - raise(UnexpectedExperimentId(experimentId)) + throw(UnexpectedExperimentId(experimentId)) } let trigger = (~experimentId, ~bucketId) => diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/Item.res b/tests/syntax_tests/data/idempotency/nook-exchange/Item.res index c55b6223a8..91565bd442 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/Item.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/Item.res @@ -115,7 +115,7 @@ let jsonToItems = (json: Js.Json.t) => { | [] => Single | [a] => OneDimension(a) | [a, b] => TwoDimensions(a, b) - | _ => raise(Unexpected) + | _ => throw(Unexpected) }, sellPrice: json->optional(field("sell", int)), buyPrice: json->optional(field("buy", int)), @@ -195,13 +195,13 @@ let isRecipe = (~item: t) => let getRecipeIdForItem = (~item: t) => switch item.type_ { | Item(recipeId) => recipeId - | Recipe(_) => raise(Constants.Uhoh) + | Recipe(_) => throw(Constants.Uhoh) } let getItemIdForRecipe = (~recipe: t) => switch recipe.type_ { | Recipe(itemId) => itemId - | Item(_) => raise(Constants.Uhoh) + | Item(_) => throw(Constants.Uhoh) } let getNumVariations = (~item) => diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/ItemCard.res b/tests/syntax_tests/data/idempotency/nook-exchange/ItemCard.res index 85455357af..86582bbcb8 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/ItemCard.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/ItemCard.res @@ -309,14 +309,14 @@ module StatusButtons = { | Wishlist => "Add to Wishlist" | ForTrade => "Add to For Trade list" | CanCraft => "Add to Can Craft list" - | CatalogOnly => raise(Constants.Uhoh) + | CatalogOnly => throw(Constants.Uhoh) }}> {React.string( switch status { | Wishlist => "+ Wishlist" | ForTrade => "+ For Trade" | CanCraft => "+ Can Craft" - | CatalogOnly => raise(Constants.Uhoh) + | CatalogOnly => throw(Constants.Uhoh) }, )} @@ -438,7 +438,7 @@ let make = (~item: Item.t, ~isLoggedIn, ~showLogin) => { switch item.type_ { | Recipe(itemId) => Item.getItem(~itemId) | Item(Some(recipeId)) => Item.getItem(~itemId=recipeId) - | Item(None) => raise(Constants.Uhoh) + | Item(None) => throw(Constants.Uhoh) } } else { item @@ -547,7 +547,7 @@ let make = (~item: Item.t, ~isLoggedIn, ~showLogin) => { | Wishlist => `In your Wishlist` | ForTrade => `In your For Trade list` | CanCraft => `In your Can Craft list` - | _ => raise(Constants.Uhoh) + | _ => throw(Constants.Uhoh) }, )} diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/ItemDetailOverlay.res b/tests/syntax_tests/data/idempotency/nook-exchange/ItemDetailOverlay.res index 0e126a3e87..51a7ece439 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/ItemDetailOverlay.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/ItemDetailOverlay.res @@ -394,7 +394,7 @@ module MyStatusSection = { | Wishlist => `In your Wishlist` | ForTrade => `In your For Trade list` | CanCraft => `In your Can Craft list` - | _ => raise(Constants.Uhoh) + | _ => throw(Constants.Uhoh) }, )} diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/ItemFilters.res b/tests/syntax_tests/data/idempotency/nook-exchange/ItemFilters.res index 6d74aba5dc..fac4258961 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/ItemFilters.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/ItemFilters.res @@ -278,7 +278,7 @@ let getSort = (~sort) => | UserTimeUpdated | UserNote | UserDefault => - raise(UnexpectedSort(sort)) + throw(UnexpectedSort(sort)) } let wrapWithVariantSort = (sort, a, b) => { @@ -363,7 +363,7 @@ let getUserItemSort = (~prioritizeViewerStatuses: array=[], ~so [0, 0], ) }) - | ListTimeAdded => raise(UnexpectedSort(sort)) + | ListTimeAdded => throw(UnexpectedSort(sort)) } module Pager = { diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/Repromise.res b/tests/syntax_tests/data/idempotency/nook-exchange/Repromise.res index dc829ea5fc..acc36ff0cf 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/Repromise.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/Repromise.res @@ -14,7 +14,7 @@ module JsExn = { | Ok(result) => result | Error(error) => Js.log2("Repromise.JsExn", error) - raise(Unexpected(error)) + throw(Unexpected(error)) }, ) ) diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/UserStore.res b/tests/syntax_tests/data/idempotency/nook-exchange/UserStore.res index 11632eb610..ab1179dbb1 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/UserStore.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/UserStore.res @@ -91,7 +91,7 @@ exception ExpectedUser let getUser = () => switch api.getState() { | LoggedIn(user) => user - | _ => raise(ExpectedUser) + | _ => throw(ExpectedUser) } let getItem = (~itemId, ~variation) => switch api.getState() { @@ -159,7 +159,7 @@ let numItemUpdatesLogged = ref(0) let setItemStatus = (~itemId: int, ~variation: int, ~status: User.itemStatus) => { let item = Item.getItem(~itemId) if Item.getCanonicalVariant(~item, ~variant=variation) != variation { - raise(NotCanonicalVariant(itemId, variation)) + throw(NotCanonicalVariant(itemId, variation)) } let user = getUser() let itemKey = User.getItemKey(~itemId, ~variation) @@ -249,7 +249,7 @@ let setItemStatusBatch = (~items: array<(int, int)>, ~status) => { let setItemNote = (~itemId: int, ~variation: int, ~note: string) => { let item = Item.getItem(~itemId) if Item.getCanonicalVariant(~item, ~variant=variation) != variation { - raise(NotCanonicalVariant(itemId, variation)) + throw(NotCanonicalVariant(itemId, variation)) } let user = getUser() let itemKey = User.getItemKey(~itemId, ~variation) diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__FileForm.res b/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__FileForm.res index c454d42a9c..2da0f2b375 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__FileForm.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__FileForm.res @@ -78,7 +78,7 @@ let submitForm = (filename, formId, send, addFileAttachmentCB) => { switch element { | Some(element) => DomUtils.FormData.create(element)->uploadFile(filename, send, addFileAttachmentCB) - | None => raise(FormNotFound(formId)) + | None => throw(FormNotFound(formId)) } } diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__Level.res b/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__Level.res index daed165c5e..cee1a6924f 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__Level.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__Level.res @@ -34,7 +34,7 @@ let first = levels => switch levels->sort { | list{} => Rollbar.error("Failed to find the first level from a course's levels.") - raise(Not_found) + throw(Not_found) | list{firstLevel, ..._rest} => firstLevel } diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__Overlay.res b/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__Overlay.res index 5ca46e85df..23c922cf81 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__Overlay.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__Overlay.res @@ -154,13 +154,13 @@ let addSubmission = (target, state, send, addSubmissionCB, submission) => { addSubmissionCB(LatestSubmission.make(~pending=false, ~targetId=target->Target.id)) | Pending => addSubmissionCB(LatestSubmission.make(~pending=true, ~targetId=target->Target.id)) | Passed => - raise( + throw( UnexpectedSubmissionStatus( "CoursesCurriculum__Overlay.addSubmission cannot handle a submsision with status Passed", ), ) | Failed => - raise( + throw( UnexpectedSubmissionStatus( "CoursesCurriculum__Overlay.addSubmission cannot handle a submsision with status Failed", ), diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__Submission.res b/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__Submission.res index 24409018d1..5c06b55c65 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__Submission.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__Submission.res @@ -39,7 +39,7 @@ let decode = json => { | "pending" => Pending | "passed" => Passed | "failed" => Failed - | unknownValue => raise(UnexpectedStatusValue(unknownValue)) + | unknownValue => throw(UnexpectedStatusValue(unknownValue)) }, checklist: json->field( "checklist", diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__Target.res b/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__Target.res index 56c437e3bf..373935bf5b 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__Target.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/courses/CoursesCurriculum__Target.res @@ -22,7 +22,7 @@ let decode = json => { role: switch json->field("role", string) { | "student" => Student | "team" => Team - | unknownRole => raise(CannotParseUnknownRole(unknownRole)) + | unknownRole => throw(CannotParseUnknownRole(unknownRole)) }, title: json->field("title", string), targetGroupId: json->field("targetGroupId", string), diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/layouts/SchoolAdminNavbar__Root.res b/tests/syntax_tests/data/idempotency/pupilfirst/layouts/SchoolAdminNavbar__Root.res index 5c5b82b7ce..2d7bc18235 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/layouts/SchoolAdminNavbar__Root.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/layouts/SchoolAdminNavbar__Root.res @@ -202,7 +202,7 @@ let make = (~schoolName, ~schoolLogoPath, ~schoolIconPath, ~courses, ~isCourseAu "Unknown path encountered by SA navbar: " ++ (url.path->Array.of_list->Js.Array.joinWith("/")), ) - raise(UnknownPathEncountered(url.path)) + throw(UnknownPathEncountered(url.path)) } [ diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/packages/MultiselectDropdown.res b/tests/syntax_tests/data/idempotency/pupilfirst/packages/MultiselectDropdown.res index 4a38b8021b..b5f65ed067 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/packages/MultiselectDropdown.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/packages/MultiselectDropdown.res @@ -10,7 +10,7 @@ module DomUtils = { let focus = id => (switch document->Document.getElementById(id) { | Some(el) => el - | None => raise(RootElementMissing(id)) + | None => throw(RootElementMissing(id)) }->Element.asHtmlElement)->Belt.Option.map(HtmlElement.focus)->ignore } diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/packs/ConvertMarkdownPack.res b/tests/syntax_tests/data/idempotency/pupilfirst/packs/ConvertMarkdownPack.res index 545ed2213e..c354038137 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/packs/ConvertMarkdownPack.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/packs/ConvertMarkdownPack.res @@ -19,7 +19,7 @@ let decodeProps = json => { let parseElement = (element, attribute) => switch element->Element.getAttribute(attribute) { | Some(props) => props - | None => raise(RootAttributeMissing(attribute)) + | None => throw(RootAttributeMissing(attribute)) } ->Json.parseOrRaise ->decodeProps @@ -30,7 +30,7 @@ let profileType = profile => | "questionAndAnswer" => Markdown.QuestionAndAnswer | "permissive" => Markdown.Permissive | "areaOfText" => Markdown.AreaOfText - | profile => raise(InvalidProfile(profile)) + | profile => throw(InvalidProfile(profile)) } let parseMarkdown = (~attributeName="convert-markdown", ~attribute="data-json-props", ()) => diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/schools/CourseAuthors__Root.res b/tests/syntax_tests/data/idempotency/pupilfirst/schools/CourseAuthors__Root.res index 3fdb65f46b..74d52b8e6c 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/schools/CourseAuthors__Root.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/schools/CourseAuthors__Root.res @@ -146,7 +146,7 @@ let make = (~courseId, ~authors) => { updateAuthorCB={author => send(UpdateAuthor(author))} /> - | otherPath => raise(UnexpectedPathOnAuthorsInterface(otherPath)) + | otherPath => throw(UnexpectedPathOnAuthorsInterface(otherPath)) } } diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/schools/CourseExports__CourseExport.res b/tests/syntax_tests/data/idempotency/pupilfirst/schools/CourseExports__CourseExport.res index 730a21b0b8..daf2749048 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/schools/CourseExports__CourseExport.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/schools/CourseExports__CourseExport.res @@ -49,7 +49,7 @@ let decode = json => { | "Teams" => Teams | otherExportType => Rollbar.error("Unexpected exportType encountered: " ++ otherExportType) - raise(UnexpectedExportType(otherExportType)) + throw(UnexpectedExportType(otherExportType)) }, reviewedOnly: json->field("reviewedOnly", bool), } diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/schools/CurriculumEditor__ContentBlockCreator.res b/tests/syntax_tests/data/idempotency/pupilfirst/schools/CurriculumEditor__ContentBlockCreator.res index fd21136f97..6f12cc6962 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/schools/CurriculumEditor__ContentBlockCreator.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/schools/CurriculumEditor__ContentBlockCreator.res @@ -204,7 +204,7 @@ let submitForm = (target, aboveContentBlock, send, addContentBlockCB, blockType) ) | None => Rollbar.error("Could not find form to upload file for content block: " ++ formId) - raise(FormNotFound(formId)) + throw(FormNotFound(formId)) } } diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/schools/CurriculumEditor__ContentBlockEditor.res b/tests/syntax_tests/data/idempotency/pupilfirst/schools/CurriculumEditor__ContentBlockEditor.res index 05b930f268..ce584e6465 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/schools/CurriculumEditor__ContentBlockEditor.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/schools/CurriculumEditor__ContentBlockEditor.res @@ -185,7 +185,7 @@ let onSave = (contentBlock, updateContentBlockCB, setDirtyCB, send, event) => { let mutation = UpdateImageBlockMutation.make(~id, ~caption, ()) let extractor = result => result["updateImageBlock"]["contentBlock"] updateContentBlockBlock(mutation, extractor, updateContentBlockCB, setDirtyCB, send) - | Embed(_) => raise(InvalidBlockTypeForUpdate) + | Embed(_) => throw(InvalidBlockTypeForUpdate) } } diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/schools/CurriculumEditor__Target.res b/tests/syntax_tests/data/idempotency/pupilfirst/schools/CurriculumEditor__Target.res index 267dffc635..cf9df6ed3a 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/schools/CurriculumEditor__Target.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/schools/CurriculumEditor__Target.res @@ -28,7 +28,7 @@ let decodeVisbility = visibilityString => | "draft" => Draft | "live" => Live | "archived" => Archived - | _ => raise(InvalidVisibilityValue("Unknown Value")) + | _ => throw(InvalidVisibilityValue("Unknown Value")) } let decode = json => { diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/schools/CurriculumEditor__TargetDetails.res b/tests/syntax_tests/data/idempotency/pupilfirst/schools/CurriculumEditor__TargetDetails.res index 32610cefb3..ec8dc9d75e 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/schools/CurriculumEditor__TargetDetails.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/schools/CurriculumEditor__TargetDetails.res @@ -41,7 +41,7 @@ let visibilityFromJs = visibilityString => | "draft" => Draft | "live" => Live | "archived" => Archived - | _ => raise(InvalidVisibilityValue("Unknown Value")) + | _ => throw(InvalidVisibilityValue("Unknown Value")) } let visibilityAsString = visibility => @@ -61,7 +61,7 @@ let roleFromJs = roleString => switch roleString { | "student" => Student | "team" => Team - | role => raise(InvalidRoleValue("Unknown Value :" ++ role)) + | role => throw(InvalidRoleValue("Unknown Value :" ++ role)) } let makeFromJs = targetData => { diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/schools/SchoolCustomize__Customizations.res b/tests/syntax_tests/data/idempotency/pupilfirst/schools/SchoolCustomize__Customizations.res index 61d7bea67c..c4041e98cb 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/schools/SchoolCustomize__Customizations.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/schools/SchoolCustomize__Customizations.res @@ -180,7 +180,7 @@ let decodeLink = json => { | "header" => HeaderLink(id, title, url) | "footer" => FooterLink(id, title, url) | "social" => SocialLink(id, url) - | unknownKind => raise(UnknownKindOfLink(unknownKind)) + | unknownKind => throw(UnknownKindOfLink(unknownKind)) } } diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/shared/ArrayUtils.res b/tests/syntax_tests/data/idempotency/pupilfirst/shared/ArrayUtils.res index 04fa217887..7af7440182 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/shared/ArrayUtils.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/shared/ArrayUtils.res @@ -29,7 +29,7 @@ let unsafeFind = (p, message, l) => "An unexpected error occurred", "Our team has been notified about this error. Please try reloading this page.", ) - raise(UnsafeFindFailed(message)) + throw(UnsafeFindFailed(message)) } let flatten = t => t->Array.to_list->List.flatten->Array.of_list diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/shared/AuthenticityToken.res b/tests/syntax_tests/data/idempotency/pupilfirst/shared/AuthenticityToken.res index 8edda90571..b742734830 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/shared/AuthenticityToken.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/shared/AuthenticityToken.res @@ -7,10 +7,10 @@ let fromHead = () => { let metaTag = document->Document.querySelector("meta[name='csrf-token']") switch metaTag { - | None => raise(CSRFTokenMissing) + | None => throw(CSRFTokenMissing) | Some(tag) => switch tag->Element.getAttribute("content") { - | None => raise(CSRFTokenEmpty) + | None => throw(CSRFTokenEmpty) | Some(token) => token } } diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/shared/ContentBlock.res b/tests/syntax_tests/data/idempotency/pupilfirst/shared/ContentBlock.res index d581b4e5a4..af99072192 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/shared/ContentBlock.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/shared/ContentBlock.res @@ -54,7 +54,7 @@ let decode = json => { | "embed" => let (url, embedCode) = json->field("content", decodeEmbedContent) Embed(url, embedCode) - | unknownBlockType => raise(UnexpectedBlockType(unknownBlockType)) + | unknownBlockType => throw(UnexpectedBlockType(unknownBlockType)) } { diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/shared/DomUtils.res b/tests/syntax_tests/data/idempotency/pupilfirst/shared/DomUtils.res index 16e15127f0..4ac4953330 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/shared/DomUtils.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/shared/DomUtils.res @@ -7,7 +7,7 @@ open Webapi.Dom let parseJsonTag = (~id="react-root-data", ()) => switch document->Document.getElementById(id) { | Some(rootElement) => rootElement->Element.innerHTML - | None => raise(DataElementMissing(id)) + | None => throw(DataElementMissing(id)) }->Json.parseOrRaise let parseJsonAttribute = (~id="react-root", ~attribute="data-json-props", ()) => @@ -15,9 +15,9 @@ let parseJsonAttribute = (~id="react-root", ~attribute="data-json-props", ()) => | Some(rootElement) => switch rootElement->Element.getAttribute(attribute) { | Some(props) => props - | None => raise(RootAttributeMissing(attribute)) + | None => throw(RootAttributeMissing(attribute)) } - | None => raise(RootElementMissing(id)) + | None => throw(RootElementMissing(id)) }->Json.parseOrRaise let redirect = path => path->Webapi.Dom.Window.setLocation(window) diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/shared/GradeLabel.res b/tests/syntax_tests/data/idempotency/pupilfirst/shared/GradeLabel.res index 6898391fb0..aeb3f359eb 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/shared/GradeLabel.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/shared/GradeLabel.res @@ -44,7 +44,7 @@ let maxGrade = gradeLabels => { switch aux(0, gradeLabels) { | 0 => Rollbar.error("GradeLabel.maxGrade received an empty list of gradeLabels") - raise(GradeLabelsEmpty) + throw(GradeLabelsEmpty) | validGrade => validGrade } } diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/shared/ListUtils.res b/tests/syntax_tests/data/idempotency/pupilfirst/shared/ListUtils.res index af77c7b784..69de71eddb 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/shared/ListUtils.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/shared/ListUtils.res @@ -17,7 +17,7 @@ let unsafeFind = (p, message, l) => try List.find(p, l) catch { | Not_found => Rollbar.error(message) - raise(UnsafeFindFailed(message)) + throw(UnsafeFindFailed(message)) } let distinct = l => { diff --git a/tests/syntax_tests/data/idempotency/pupilfirst/shared/MarkdownEditor.res b/tests/syntax_tests/data/idempotency/pupilfirst/shared/MarkdownEditor.res index c894c59d62..4a229274d1 100644 --- a/tests/syntax_tests/data/idempotency/pupilfirst/shared/MarkdownEditor.res +++ b/tests/syntax_tests/data/idempotency/pupilfirst/shared/MarkdownEditor.res @@ -317,7 +317,7 @@ let previewType = mode => switch mode { | Windowed(#Editor) | Fullscreen(#Editor) => - raise(InvalidModeForPreview) + throw(InvalidModeForPreview) | Windowed(#Preview) => #WindowedPreview | Fullscreen(#Split) => #FullscreenSplit | Fullscreen(#Preview) => #FullscreenPreview diff --git a/tests/syntax_tests/data/idempotency/reason-react/src/ReactDOMRe.res b/tests/syntax_tests/data/idempotency/reason-react/src/ReactDOMRe.res index f77cc05eb0..49b21613c0 100644 --- a/tests/syntax_tests/data/idempotency/reason-react/src/ReactDOMRe.res +++ b/tests/syntax_tests/data/idempotency/reason-react/src/ReactDOMRe.res @@ -16,7 +16,7 @@ external _getElementById: string => option = "document.getElementBy let renderToElementWithClassName = (reactElement, className) => switch _getElementsByClassName(className) { | [] => - raise( + throw( Invalid_argument( "ReactDOMRe.renderToElementWithClassName: no element of class " ++ (className ++ @@ -29,7 +29,7 @@ let renderToElementWithClassName = (reactElement, className) => let renderToElementWithId = (reactElement, id) => switch _getElementById(id) { | None => - raise( + throw( Invalid_argument( "ReactDOMRe.renderToElementWithId : no element of id " ++ (id ++ " found in the HTML."), ), @@ -43,7 +43,7 @@ external hydrate: (React.element, Dom.element) => unit = "hydrate" let hydrateToElementWithClassName = (reactElement, className) => switch _getElementsByClassName(className) { | [] => - raise( + throw( Invalid_argument( "ReactDOMRe.hydrateToElementWithClassName: no element of class " ++ (className ++ @@ -56,7 +56,7 @@ let hydrateToElementWithClassName = (reactElement, className) => let hydrateToElementWithId = (reactElement, id) => switch _getElementById(id) { | None => - raise( + throw( Invalid_argument( "ReactDOMRe.hydrateToElementWithId : no element of id " ++ (id ++ " found in the HTML."), ), diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/block.res b/tests/syntax_tests/data/parsing/grammar/expressions/block.res index a7af95bc5c..c386331949 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/block.res +++ b/tests/syntax_tests/data/parsing/grammar/expressions/block.res @@ -14,7 +14,7 @@ let b = { let b = { exception QuitEarly - raise(QuitEarly) + throw(QuitEarly) } // let-bindings @@ -59,7 +59,7 @@ let b = { let b = 2; sideEffect(); let x = (1 + 2)->(x => x + 1); - raise(Terminate(x)); + throw(Terminate(x)); } let b = { @@ -143,7 +143,7 @@ let reifyStyle = (type a, x: 'a): (style, a) => { } else if Internal.instanceOf(x, Internal.canvasPattern) { Obj.magic(Pattern) } else { - raise( + throw( Invalid_argument( "Unknown canvas style kind. Known values are: String, CanvasGradient, CanvasPattern", ), diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/block.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/block.res.txt index 81b64a4216..42814ef53e 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/block.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/block.res.txt @@ -6,7 +6,7 @@ let b = ((let open Belt.Array in ([|1;2|] -> (map (fun [arity:1]x -> x + 1))) -> Js.log) [@res.braces ]) -let b = ((let exception QuitEarly in raise QuitEarly)[@res.braces ]) +let b = ((let exception QuitEarly in throw QuitEarly)[@res.braces ]) let b = ((let a = 1 in let b = 2 in a + b)[@res.braces ]) let b = ((let _ = sideEffect () in ())[@res.braces ]) let b = ((let _ = sideEffect () in ())[@res.braces ]) @@ -21,7 +21,7 @@ let b = let b = 2 in sideEffect (); (let x = (1 + 2) -> (fun [arity:1]x -> x + 1) in - raise (Terminate x))) + throw (Terminate x))) [@res.braces ]) let b = ((f (); g (); h (); (let arr = [|1;2;3|] in ()))[@res.braces ]) let res = @@ -64,7 +64,7 @@ let reifyStyle (type a) [arity:1](x : 'a) = if Internal.instanceOf x Internal.canvasPattern then Obj.magic Pattern else - raise + throw (Invalid_argument {js|Unknown canvas style kind. Known values are: String, CanvasGradient, CanvasPattern|js})), (Obj.magic x))) diff --git a/tests/syntax_tests/data/printer/comments/blockExpr.res b/tests/syntax_tests/data/printer/comments/blockExpr.res index 8f1aca233e..e571446a2e 100644 --- a/tests/syntax_tests/data/printer/comments/blockExpr.res +++ b/tests/syntax_tests/data/printer/comments/blockExpr.res @@ -100,7 +100,7 @@ let () = { let () = { /* c0 */ exception /* inside */ Exit /* c1 */ - /* c2 */ raise(Exit) /* c3 */ + /* c2 */ throw(Exit) /* c3 */ } let () = { @@ -108,13 +108,13 @@ let () = { // k // k2 - /* c2 */ raise(Exit) // c3 + /* c2 */ throw(Exit) // c3 } let () = { /* c0 */ exception /* inside */ Exit /* c1 */ /* c2 */ exception /* inside */ Terminate /* c3 */ - /* c4 */ raise(Exit) /* c5 */ + /* c4 */ throw(Exit) /* c5 */ } let () = { @@ -130,14 +130,14 @@ let () = { // k2 // k3 - /* c4 */ raise(Exit) /* c5 */ + /* c4 */ throw(Exit) /* c5 */ } let () = { /* c0 */ exception /* inside */ Exit /* c1 */ /* c2 */ exception /* inside */ Terminate /* c3 */ /* c4 */ exception /* inside */ Oom /* c5 */ - /* c6 */ raise(Exit) /* c7 */ + /* c6 */ throw(Exit) /* c7 */ } let () = { diff --git a/tests/syntax_tests/data/printer/comments/expected/blockExpr.res.txt b/tests/syntax_tests/data/printer/comments/expected/blockExpr.res.txt index a2efeccdc3..9c08337639 100644 --- a/tests/syntax_tests/data/printer/comments/expected/blockExpr.res.txt +++ b/tests/syntax_tests/data/printer/comments/expected/blockExpr.res.txt @@ -99,7 +99,7 @@ let () = { let () = { /* c0 */ exception /* inside */ Exit /* c1 */ - /* c2 */ raise(Exit) /* c3 */ + /* c2 */ throw(Exit) /* c3 */ } let () = { @@ -107,13 +107,13 @@ let () = { // k // k2 - /* c2 */ raise(Exit) // c3 + /* c2 */ throw(Exit) // c3 } let () = { /* c0 */ exception /* inside */ Exit /* c1 */ /* c2 */ exception /* inside */ Terminate /* c3 */ - /* c4 */ raise(Exit) /* c5 */ + /* c4 */ throw(Exit) /* c5 */ } let () = { @@ -129,14 +129,14 @@ let () = { // k2 // k3 - /* c4 */ raise(Exit) /* c5 */ + /* c4 */ throw(Exit) /* c5 */ } let () = { /* c0 */ exception /* inside */ Exit /* c1 */ /* c2 */ exception /* inside */ Terminate /* c3 */ /* c4 */ exception /* inside */ Oom /* c5 */ - /* c6 */ raise(Exit) /* c7 */ + /* c6 */ throw(Exit) /* c7 */ } let () = { diff --git a/tests/syntax_tests/data/printer/expr/apply.res b/tests/syntax_tests/data/printer/expr/apply.res index d39742b986..2516fa65a8 100644 --- a/tests/syntax_tests/data/printer/expr/apply.res +++ b/tests/syntax_tests/data/printer/expr/apply.res @@ -70,7 +70,7 @@ f(. { f(. {expr}) f(. { exception Exit - raise(Exit) + throw(Exit) }) resolve(.) diff --git a/tests/syntax_tests/data/printer/expr/binary.res b/tests/syntax_tests/data/printer/expr/binary.res index 9988c68b50..18e9a73863 100644 --- a/tests/syntax_tests/data/printer/expr/binary.res +++ b/tests/syntax_tests/data/printer/expr/binary.res @@ -250,8 +250,8 @@ let x = a && (truth: bool) && (otherTruth: bool) let x = a && {module L = Log; L.log()} let x = a && {module L = Log; L.log()} && {module L = Log; L.log()} -let x = a && {exception Exit; raise(Exit)} -let x = a && {exception Exit; raise(Exit)} && {exception Exit; raise(Exit)} +let x = a && {exception Exit; throw(Exit)} +let x = a && {exception Exit; throw(Exit)} && {exception Exit; throw(Exit)} let x = a && assert(false) let x = a && assert(false) && assert(true) diff --git a/tests/syntax_tests/data/printer/expr/block.res b/tests/syntax_tests/data/printer/expr/block.res index 1a53984ab6..169de18a7b 100644 --- a/tests/syntax_tests/data/printer/expr/block.res +++ b/tests/syntax_tests/data/printer/expr/block.res @@ -31,7 +31,7 @@ let reifyStyle = (type a, x: 'a): (style, a) => { } else if Internal.instanceOf(x, Internal.canvasPattern) { Obj.magic(Pattern) } else { - raise( + throw( Invalid_argument( "Unknown canvas style kind. Known values are: String, CanvasGradient, CanvasPattern", ), diff --git a/tests/syntax_tests/data/printer/expr/constructor.res b/tests/syntax_tests/data/printer/expr/constructor.res index b72a2db3eb..a75d263041 100644 --- a/tests/syntax_tests/data/printer/expr/constructor.res +++ b/tests/syntax_tests/data/printer/expr/constructor.res @@ -112,7 +112,7 @@ let first = Some({ let first = Some({ exception Exit - raise(Exit) + throw(Exit) }) let first = Some({ diff --git a/tests/syntax_tests/data/printer/expr/expected/apply.res.txt b/tests/syntax_tests/data/printer/expr/expected/apply.res.txt index 5cae622f79..780fb3e6ac 100644 --- a/tests/syntax_tests/data/printer/expr/expected/apply.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/apply.res.txt @@ -90,7 +90,7 @@ f({ f({expr}) f({ exception Exit - raise(Exit) + throw(Exit) }) resolve() diff --git a/tests/syntax_tests/data/printer/expr/expected/binary.res.txt b/tests/syntax_tests/data/printer/expr/expected/binary.res.txt index 71672d816d..60943941c1 100644 --- a/tests/syntax_tests/data/printer/expr/expected/binary.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/binary.res.txt @@ -363,16 +363,16 @@ let x = let x = a && { exception Exit - raise(Exit) + throw(Exit) } let x = a && { exception Exit - raise(Exit) + throw(Exit) } && { exception Exit - raise(Exit) + throw(Exit) } let x = a && assert(false) diff --git a/tests/syntax_tests/data/printer/expr/expected/block.res.txt b/tests/syntax_tests/data/printer/expr/expected/block.res.txt index d7d8068b79..62db8f040f 100644 --- a/tests/syntax_tests/data/printer/expr/expected/block.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/block.res.txt @@ -31,7 +31,7 @@ let reifyStyle = (type a, x: 'a): (style, a) => { } else if Internal.instanceOf(x, Internal.canvasPattern) { Obj.magic(Pattern) } else { - raise( + throw( Invalid_argument( "Unknown canvas style kind. Known values are: String, CanvasGradient, CanvasPattern", ), diff --git a/tests/syntax_tests/data/printer/expr/expected/constructor.res.txt b/tests/syntax_tests/data/printer/expr/expected/constructor.res.txt index 69d4b65925..f64ace585c 100644 --- a/tests/syntax_tests/data/printer/expr/expected/constructor.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/constructor.res.txt @@ -117,7 +117,7 @@ let first = Some({ let first = Some({ exception Exit - raise(Exit) + throw(Exit) }) let first = Some({ diff --git a/tests/syntax_tests/data/printer/expr/expected/jsx.res.txt b/tests/syntax_tests/data/printer/expr/expected/jsx.res.txt index aa8bd59e80..2bf6cdf045 100644 --- a/tests/syntax_tests/data/printer/expr/expected/jsx.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/jsx.res.txt @@ -190,7 +190,7 @@ let x = } letException={ exception Exit - raise(Exit) + throw(Exit) } assertExpr={assert(true)} pack=module(Foo) @@ -269,7 +269,7 @@ let x = } { exception Exit - raise(Exit) + throw(Exit) } {assert(true)} {module(Foo)} diff --git a/tests/syntax_tests/data/printer/expr/expected/ternary.res.txt b/tests/syntax_tests/data/printer/expr/expected/ternary.res.txt index 7b81daec25..6de00d0786 100644 --- a/tests/syntax_tests/data/printer/expr/expected/ternary.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/ternary.res.txt @@ -217,7 +217,7 @@ let () = condition } : { exception Exit - raise(Exit) + throw(Exit) } let () = condition ? foo() : assert(false) diff --git a/tests/syntax_tests/data/printer/expr/jsx.res b/tests/syntax_tests/data/printer/expr/jsx.res index caeaf61baa..a76d07981c 100644 --- a/tests/syntax_tests/data/printer/expr/jsx.res +++ b/tests/syntax_tests/data/printer/expr/jsx.res @@ -174,7 +174,7 @@ let x = }} letException={{ exception Exit; - raise(Exit) + throw(Exit) }} assertExpr={assert(true)} pack=module(Foo) @@ -245,7 +245,7 @@ let x = }} {{ exception Exit; - raise(Exit) + throw(Exit) }} {assert(true)} {module(Foo)} diff --git a/tests/syntax_tests/data/printer/expr/ternary.res b/tests/syntax_tests/data/printer/expr/ternary.res index 51725ca0a4..23402df2b3 100644 --- a/tests/syntax_tests/data/printer/expr/ternary.res +++ b/tests/syntax_tests/data/printer/expr/ternary.res @@ -98,7 +98,7 @@ let () = condition1 ? for i in 0 to 10 { () } : for i in 10 to 20 { () } let () = (truth : bool) ? (10: int) : (20: int) -let () = condition ? {module L = Logger; L.log()} : {exception Exit; raise(Exit)} +let () = condition ? {module L = Logger; L.log()} : {exception Exit; throw(Exit)} let () = condition ? foo() : assert(false) let x = condition ? module(Foo) : module(Int : Number) diff --git a/tests/tests/src/UncurriedExternals.res b/tests/tests/src/UncurriedExternals.res index 8de1186b81..73ed2e6888 100644 --- a/tests/tests/src/UncurriedExternals.res +++ b/tests/tests/src/UncurriedExternals.res @@ -1,6 +1,6 @@ module StandardNotation = { external raise: exn => 'a = "%raise" - let dd = () => raise(Not_found) + let dd = () => throw(Not_found) @val external sum: (float, float) => float = "sum" let h = sum(1.0, 2.0) diff --git a/tests/tests/src/arity_infer.res b/tests/tests/src/arity_infer.res index dd88860b2f..9fc294563f 100644 --- a/tests/tests/src/arity_infer.res +++ b/tests/tests/src/arity_infer.res @@ -3,11 +3,11 @@ let f0 = x => if x > 3 { x => x + 1 } else { - raise(Not_found) + throw(Not_found) } )(3) -let f1 = x => (raise(Not_found): _ => _)(x) +let f1 = x => (throw(Not_found): _ => _)(x) let f3 = x => ( @@ -16,6 +16,6 @@ let f3 = x => | 1 => x => x + 2 | 2 => x => x + 3 | 3 => x => x + 4 - | _ => raise(Not_found) + | _ => throw(Not_found) } )(3) diff --git a/tests/tests/src/core/Core_PromiseTest.res b/tests/tests/src/core/Core_PromiseTest.res index e017071e43..0040daba61 100644 --- a/tests/tests/src/core/Core_PromiseTest.res +++ b/tests/tests/src/core/Core_PromiseTest.res @@ -146,7 +146,7 @@ module Catching = { resolve() ->then(_ => { - raise(TestError("Thrown exn")) + throw(TestError("Thrown exn")) }) ->catch(e => { let isTestErr = switch e { diff --git a/tests/tests/src/core/Core_TempTests.res b/tests/tests/src/core/Core_TempTests.res index 982ea21f73..748e6a1dff 100644 --- a/tests/tests/src/core/Core_TempTests.res +++ b/tests/tests/src/core/Core_TempTests.res @@ -28,8 +28,8 @@ Console.info("---") let f = () => { let error = Error.make("hello") let typeError = Error.TypeError.make("error") - let g = () => Error.raise(error) - let h = () => Error.raise(typeError) + let g = () => Error.throw(error) + let h = () => Error.throw(typeError) (g, h) } diff --git a/tests/tests/src/custom_error_test.res b/tests/tests/src/custom_error_test.res index 78a24a1dda..0420f7e5c1 100644 --- a/tests/tests/src/custom_error_test.res +++ b/tests/tests/src/custom_error_test.res @@ -10,7 +10,7 @@ let test_js_error2 = () => try Js.Json.parseExn(` {"x" : }`) catch { | Js.Exn.Error(err) as e => Js.log(Js.Exn.stack(err)) - raise(e) + throw(e) } let example1 = () => diff --git a/tests/tests/src/equal_exception_test.res b/tests/tests/src/equal_exception_test.res index 5b673bf1fc..1e583469e1 100644 --- a/tests/tests/src/equal_exception_test.res +++ b/tests/tests/src/equal_exception_test.res @@ -7,7 +7,7 @@ let is_equal = () => { } let is_exception = () => - try raise(Not_found) catch { + try throw(Not_found) catch { | Not_found => () } @@ -16,7 +16,7 @@ let is_normal_exception = _x => { exception A(int) } let v = E.A(3) - try raise(v) catch { + try throw(v) catch { | E.A(3) => () } } @@ -25,7 +25,7 @@ let is_arbitrary_exception = () => { module E = { exception A } - try raise(E.A) catch { + try throw(E.A) catch { | _ => () } } diff --git a/tests/tests/src/exception_raise_test.res b/tests/tests/src/exception_raise_test.res index 407bc1597e..ecb027e4e3 100644 --- a/tests/tests/src/exception_raise_test.res +++ b/tests/tests/src/exception_raise_test.res @@ -137,7 +137,7 @@ let () = try %raw(`()=>{throw 2}`)() catch { | e => eq(__LOC__, Js.Exn.asJsExn(e) != None, true) } -let () = try raise(Not_found) catch { +let () = try throw(Not_found) catch { | e => eq(__LOC__, Js.Exn.asJsExn(e) != None, false) } diff --git a/tests/tests/src/exception_value_test.res b/tests/tests/src/exception_value_test.res index b5b753e290..f24bf9300d 100644 --- a/tests/tests/src/exception_value_test.res +++ b/tests/tests/src/exception_value_test.res @@ -1,4 +1,4 @@ -let f = () => raise(Not_found) +let f = () => throw(Not_found) let assert_f = x => { let () = assert(x > 3) @@ -6,7 +6,7 @@ let assert_f = x => { } let hh = () => { - let v = raise(Not_found) + let v = throw(Not_found) v + 3 } /* TODO: comment for line column number */ @@ -26,7 +26,7 @@ let test_js_error2 = () => try Js.Json.parseExn(` {"x" : }`) catch { | Js.Exn.Error(err) as e => Js.log(Js.Exn.stack(err)) - raise(e) + throw(e) } let test_js_error3 = () => diff --git a/tests/tests/src/flexible_array_test.res b/tests/tests/src/flexible_array_test.res index 95b178dab2..019c6ac092 100644 --- a/tests/tests/src/flexible_array_test.res +++ b/tests/tests/src/flexible_array_test.res @@ -6,7 +6,7 @@ type rec tree<'a> = let rec sub = (tr: tree<_>, k) => switch tr { - | Lf => raise(Not_found) + | Lf => throw(Not_found) | Br(v, l, r) => if k == 1 { v @@ -23,7 +23,7 @@ let rec update = (tr: tree<_>, k, w) => if k == 1 { Br(w, Lf, Lf) } else { - raise(Not_found) + throw(Not_found) } | Br(v, l, r) => if k == 1 { @@ -37,7 +37,7 @@ let rec update = (tr: tree<_>, k, w) => let rec delete = (tr: tree<_>, n) => switch tr { - | Lf => raise(Not_found) + | Lf => throw(Not_found) | Br(v, l, r) => if n == 1 { Lf @@ -73,7 +73,7 @@ let rec loext = (tr: tree<_>, w) => /* pop_back */ let rec lorem = (tr: tree<_>) => switch tr { - | Lf => raise(Not_found) + | Lf => throw(Not_found) | Br(w, Lf, Lf) => Lf /* length = 1 */ | Br(w, Br(v, ll, lr) as l, r) => diff --git a/tests/tests/src/gpr_1701_test.res b/tests/tests/src/gpr_1701_test.res index 371efe038b..6c8a985045 100644 --- a/tests/tests/src/gpr_1701_test.res +++ b/tests/tests/src/gpr_1701_test.res @@ -4,7 +4,7 @@ exception Foo let rec test = n => if n == 0 { - raise(Foo) + throw(Foo) } else { try test(n - 1) catch { | Foo => () diff --git a/tests/tests/src/inline_map2_test.res b/tests/tests/src/inline_map2_test.res index ce07a4b912..25648842f0 100644 --- a/tests/tests/src/inline_map2_test.res +++ b/tests/tests/src/inline_map2_test.res @@ -151,7 +151,7 @@ module Make = (Ord: OrderedType) => { let rec find = (x, x_) => switch x_ { - | Empty => raise(Not_found) + | Empty => throw(Not_found) | Node(l, v, d, r, _) => let c = Ord.compare(x, v) if c == 0 { @@ -186,14 +186,14 @@ module Make = (Ord: OrderedType) => { let rec min_binding = x => switch x { - | Empty => raise(Not_found) + | Empty => throw(Not_found) | Node(Empty, x, d, r, _) => (x, d) | Node(l, x, d, r, _) => min_binding(l) } let rec max_binding = x => switch x { - | Empty => raise(Not_found) + | Empty => throw(Not_found) | Node(l, x, d, Empty, _) => (x, d) | Node(l, x, d, r, _) => max_binding(r) } diff --git a/tests/tests/src/inline_map_demo.res b/tests/tests/src/inline_map_demo.res index 78877b5bc3..762748c8c4 100644 --- a/tests/tests/src/inline_map_demo.res +++ b/tests/tests/src/inline_map_demo.res @@ -118,7 +118,7 @@ let m = Belt.List.reduceReverse(list{(10, 'a'), (3, 'b'), (7, 'c'), (20, 'd')}, let rec find = (px, x) => switch x { - | Empty => raise(Not_found) + | Empty => throw(Not_found) | Node(l, v, d, r, _) => let c = compare(px, v) if c == 0 { diff --git a/tests/tests/src/inline_map_test.res b/tests/tests/src/inline_map_test.res index 927babcfe3..b7b65e6acd 100644 --- a/tests/tests/src/inline_map_test.res +++ b/tests/tests/src/inline_map_test.res @@ -109,7 +109,7 @@ let rec add = (x, data, x_) => let rec find = (x, x_) => switch x_ { - | Empty => raise(Not_found) + | Empty => throw(Not_found) | Node(l, v, d, r, _) => let c = compare(x, v) if c == 0 { @@ -144,14 +144,14 @@ let rec mem = (x, x_) => let rec min_binding = x => switch x { - | Empty => raise(Not_found) + | Empty => throw(Not_found) | Node(Empty, x, d, r, _) => (x, d) | Node(l, x, d, r, _) => min_binding(l) } let rec max_binding = x => switch x { - | Empty => raise(Not_found) + | Empty => throw(Not_found) | Node(l, x, d, Empty, _) => (x, d) | Node(l, x, d, r, _) => max_binding(r) } diff --git a/tests/tests/src/js_exception_catch_test.res b/tests/tests/src/js_exception_catch_test.res index ee05cb00d6..3d9d89ec56 100644 --- a/tests/tests/src/js_exception_catch_test.res +++ b/tests/tests/src/js_exception_catch_test.res @@ -42,14 +42,14 @@ let test = f => let () = { eq(__LOC__, test(_ => ()), #No_error) - eq(__LOC__, test(_ => raise(Not_found)), #Not_found) + eq(__LOC__, test(_ => throw(Not_found)), #Not_found) eq(__LOC__, test(_ => invalid_arg("x")), #Invalid_argument) eq(__LOC__, test(_ => invalid_arg("")), #Invalid_any) - eq(__LOC__, test(_ => raise(A(2))), #A2) - eq(__LOC__, test(_ => raise(A(3))), #A_any) - eq(__LOC__, test(_ => raise(B)), #B) - eq(__LOC__, test(_ => raise(C(1, 2))), #C) - eq(__LOC__, test(_ => raise(C(0, 2))), #C_any) + eq(__LOC__, test(_ => throw(A(2))), #A2) + eq(__LOC__, test(_ => throw(A(3))), #A_any) + eq(__LOC__, test(_ => throw(B)), #B) + eq(__LOC__, test(_ => throw(C(1, 2))), #C) + eq(__LOC__, test(_ => throw(C(0, 2))), #C_any) eq(__LOC__, test(_ => Js.Exn.raiseError("x")), #Js_error) eq(__LOC__, test(_ => failwith("x")), #Any) } diff --git a/tests/tests/src/lazy_test.res b/tests/tests/src/lazy_test.res index a5a9d59c4b..5a6b8c6ca7 100644 --- a/tests/tests/src/lazy_test.res +++ b/tests/tests/src/lazy_test.res @@ -52,10 +52,10 @@ let f006: Lazy.t int> = Lazy.make(() => { _ => x }) -let f007 = Lazy.make(() => raise(Not_found)) +let f007 = Lazy.make(() => throw(Not_found)) let f008 = Lazy.make(() => { Js.log("hi") - raise(Not_found) + throw(Not_found) }) let a2 = x => Lazy.from_val(x) @@ -93,7 +93,7 @@ Mt.from_pair_suites( (__FILE__, _ => Eq(a7, None)), (__FILE__, _ => Eq(a8, ())), (__LOC__, _ => Ok(Lazy.isEvaluated(Lazy.from_val(3)))), - (__LOC__, _ => Ok(!Lazy.isEvaluated(Lazy.make(() => raise(Not_found))))), + (__LOC__, _ => Ok(!Lazy.isEvaluated(Lazy.make(() => throw(Not_found))))), } }, ) diff --git a/tests/tests/src/ocaml_compat/Ocaml_Array.res b/tests/tests/src/ocaml_compat/Ocaml_Array.res index a72920bd5f..4f714df4e3 100644 --- a/tests/tests/src/ocaml_compat/Ocaml_Array.res +++ b/tests/tests/src/ocaml_compat/Ocaml_Array.res @@ -263,7 +263,7 @@ let sort = (cmp, a) => { } else if i31 < l { i31 } else { - raise(Bottom(i)) + throw(Bottom(i)) } } diff --git a/tests/tests/src/ocaml_compat/Ocaml_List.res b/tests/tests/src/ocaml_compat/Ocaml_List.res index 334b2f8937..30369323b3 100644 --- a/tests/tests/src/ocaml_compat/Ocaml_List.res +++ b/tests/tests/src/ocaml_compat/Ocaml_List.res @@ -245,7 +245,7 @@ let rec memq = (x, param) => let rec assoc = (x, param) => switch param { - | list{} => raise(Not_found) + | list{} => throw(Not_found) | list{(a, b), ...l} => if compare(a, x) == 0 { b @@ -267,7 +267,7 @@ let rec assoc_opt = (x, param) => let rec assq = (x, param) => switch param { - | list{} => raise(Not_found) + | list{} => throw(Not_found) | list{(a, b), ...l} => if a === x { b @@ -323,7 +323,7 @@ let rec remove_assq = (x, param) => let rec find = (p, param) => switch param { - | list{} => raise(Not_found) + | list{} => throw(Not_found) | list{x, ...l} => if p(x) { x diff --git a/tests/tests/src/ocaml_compat/Ocaml_String.res b/tests/tests/src/ocaml_compat/Ocaml_String.res index 2c0f049e68..f839830d4c 100644 --- a/tests/tests/src/ocaml_compat/Ocaml_String.res +++ b/tests/tests/src/ocaml_compat/Ocaml_String.res @@ -91,7 +91,7 @@ let escaped = s => { /* duplicated in bytes.ml */ let rec index_rec = (s, lim, i, c) => if i >= lim { - raise(Not_found) + throw(Not_found) } else if unsafe_get(s, i) == c { i } else { @@ -137,7 +137,7 @@ let index_from_opt = (s, i, c) => { /* duplicated in bytes.ml */ let rec rindex_rec = (s, i, c) => if i < 0 { - raise(Not_found) + throw(Not_found) } else if unsafe_get(s, i) == c { i } else { diff --git a/tests/tests/src/pq_test.res b/tests/tests/src/pq_test.res index 115213c9ac..4e1e0eec28 100644 --- a/tests/tests/src/pq_test.res +++ b/tests/tests/src/pq_test.res @@ -15,7 +15,7 @@ module PrioQueue = { exception Queue_is_empty let rec remove_top = x => switch x { - | Empty => raise(Queue_is_empty) + | Empty => throw(Queue_is_empty) | Node(prio, elt, left, Empty) => left | Node(prio, elt, Empty, right) => right | Node(prio, elt, Node(lprio, lelt, _, _) as left, Node(rprio, relt, _, _) as right) => @@ -27,7 +27,7 @@ module PrioQueue = { } let extract = x => switch x { - | Empty => raise(Queue_is_empty) + | Empty => throw(Queue_is_empty) | Node(prio, elt, _, _) as queue => (prio, elt, remove_top(queue)) } } diff --git a/tests/tests/src/queue_402.res b/tests/tests/src/queue_402.res index a8268af2ff..e80944c4ac 100644 --- a/tests/tests/src/queue_402.res +++ b/tests/tests/src/queue_402.res @@ -76,7 +76,7 @@ let push = add let peek = q => if q.length == 0 { - raise(Empty) + throw(Empty) } else { q.tail.next.content } @@ -85,7 +85,7 @@ let top = peek let take = q => { if q.length == 0 { - raise(Empty) + throw(Empty) } q.length = q.length - 1 let tail = q.tail diff --git a/tests/tests/src/reasonReact.res b/tests/tests/src/reasonReact.res index 291e60d0fa..c86c69ef87 100644 --- a/tests/tests/src/reasonReact.res +++ b/tests/tests/src/reasonReact.res @@ -160,7 +160,7 @@ let convertPropsIfTheyreFromJs = (props, jsPropsToReason, debugName) => { | (Some(props), _) => props | (None, Some(toReasonProps)) => Element(toReasonProps(props)) | (None, None) => - raise( + throw( Invalid_argument( "A JS component called the Reason component " ++ (debugName ++ diff --git a/tests/tests/src/record_extension_test.res b/tests/tests/src/record_extension_test.res index 4216f1f3b2..176fa92c34 100644 --- a/tests/tests/src/record_extension_test.res +++ b/tests/tests/src/record_extension_test.res @@ -62,8 +62,8 @@ let u = f => | _ => -1 } -eq(__LOC__, u(() => raise(A({name: 1, x: 1}))), 2) -eq(__LOC__, u(() => raise(B(1, 2))), 3) -eq(__LOC__, u(() => raise(C({name: 4}))), 4) +eq(__LOC__, u(() => throw(A({name: 1, x: 1}))), 2) +eq(__LOC__, u(() => throw(B(1, 2))), 3) +eq(__LOC__, u(() => throw(C({name: 4}))), 4) let () = Mt.from_pair_suites(__LOC__, suites.contents) diff --git a/tests/tests/src/set_gen.res b/tests/tests/src/set_gen.res index 7665f3291e..d9c0a898f0 100644 --- a/tests/tests/src/set_gen.res +++ b/tests/tests/src/set_gen.res @@ -37,14 +37,14 @@ let rec height = x => let rec min_elt = x => switch x { - | Empty => raise(Not_found) + | Empty => throw(Not_found) | Node(Empty, v, r, _) => v | Node(l, v, r, _) => min_elt(l) } let rec max_elt = x => switch x { - | Empty => raise(Not_found) + | Empty => throw(Not_found) | Node(l, v, Empty, _) => v | Node(l, v, r, _) => max_elt(r) } @@ -131,11 +131,11 @@ let rec check_height_and_diff = x => let hl = check_height_and_diff(l) let hr = check_height_and_diff(r) if h != max_int_2(hl, hr) + 1 { - raise(Height_invariant_broken) + throw(Height_invariant_broken) } else { let diff = abs(hl - hr) if diff > 2 { - raise(Height_diff_borken) + throw(Height_diff_borken) } else { h } diff --git a/tests/tests/src/string_set.res b/tests/tests/src/string_set.res index 14334124f3..fa50691bb1 100644 --- a/tests/tests/src/string_set.res +++ b/tests/tests/src/string_set.res @@ -169,7 +169,7 @@ let rec subset = (s1: Set_gen.t<_>, s2: Set_gen.t<_>) => let rec find = (x, tree: Set_gen.t<_>) => switch tree { - | Empty => raise(Not_found) + | Empty => throw(Not_found) | Node(l, v, r, _) => let c = compare_elt(x, v) if c == 0 { diff --git a/tests/tests/src/test_exception.res b/tests/tests/src/test_exception.res index ee7b437d48..5ffa77f632 100644 --- a/tests/tests/src/test_exception.res +++ b/tests/tests/src/test_exception.res @@ -1,13 +1,13 @@ exception Local(int) -let f = () => raise(Local(3)) +let f = () => throw(Local(3)) -let g = () => raise(Not_found) +let g = () => throw(Not_found) -let h = () => raise(Test_common.U(3)) -let x = () => raise(Test_common.H) +let h = () => throw(Test_common.U(3)) +let x = () => throw(Test_common.H) -let xx = () => raise(Invalid_argument("x")) +let xx = () => throw(Invalid_argument("x")) exception Nullary diff --git a/tests/tests/src/test_exception_escape.res b/tests/tests/src/test_exception_escape.res index 9c90719ba1..852059b38c 100644 --- a/tests/tests/src/test_exception_escape.res +++ b/tests/tests/src/test_exception_escape.res @@ -2,7 +2,7 @@ module N: { let f: int } = { exception A(int) - let f = try raise(A(3)) catch { + let f = try throw(A(3)) catch { | _ => 3 } } diff --git a/tests/tests/src/test_list.res b/tests/tests/src/test_list.res index 44b9db0ac1..8de56dbec6 100644 --- a/tests/tests/src/test_list.res +++ b/tests/tests/src/test_list.res @@ -210,7 +210,7 @@ let rec memq = (x, x_) => let rec assoc = (x, x_) => switch x_ { - | list{} => raise(Not_found) + | list{} => throw(Not_found) | list{(a, b), ...l} => if compare(a, x) == 0 { b @@ -221,7 +221,7 @@ let rec assoc = (x, x_) => let rec assq = (x, x_) => switch x_ { - | list{} => raise(Not_found) + | list{} => throw(Not_found) | list{(a, b), ...l} => if a === x { b @@ -266,7 +266,7 @@ let rec remove_assq = (x, x_) => let rec find = (p, x) => switch x { - | list{} => raise(Not_found) + | list{} => throw(Not_found) | list{x, ...l} => if p(x) { x diff --git a/tests/tests/src/test_per.res b/tests/tests/src/test_per.res index 1ecbd2f262..b53ba0515d 100644 --- a/tests/tests/src/test_per.res +++ b/tests/tests/src/test_per.res @@ -1,10 +1,9 @@ /* Exceptions */ external raise: exn => 'a = "%raise" -external raise_notrace: exn => 'a = "%raise_notrace" -let failwith = s => raise(Failure(s)) -let invalid_arg = s => raise(Invalid_argument(s)) +let failwith = s => throw(Failure(s)) +let invalid_arg = s => throw(Invalid_argument(s)) exception Exit diff --git a/tests/tests/src/test_seq.res b/tests/tests/src/test_seq.res index 753ef98b43..8927d6119a 100644 --- a/tests/tests/src/test_seq.res +++ b/tests/tests/src/test_seq.res @@ -49,7 +49,7 @@ exception Stop(error) /* used internally */ let rec assoc3 = (x, l) => switch l { - | list{} => raise(Not_found) + | list{} => throw(Not_found) | list{(y1, y2, y3), ...t} if y1 == x => y2 | list{_, ...t} => assoc3(x, t) } @@ -69,7 +69,7 @@ let rec assoc3 = (x, l) => /* bprintf buf " %s %s\n" key doc */ /* ;; */ -let help_action = () => raise(Stop(Unknown("-help"))) +let help_action = () => throw(Stop(Unknown("-help"))) let v = speclist => { ignore(assoc3("-help", speclist)) list{} diff --git a/tests/tests/src/test_set.res b/tests/tests/src/test_set.res index 1abeb01034..a483109708 100644 --- a/tests/tests/src/test_set.res +++ b/tests/tests/src/test_set.res @@ -200,14 +200,14 @@ module Make = (Ord: OrderedType) => { let rec min_elt = x => switch x { - | Empty => raise(Not_found) + | Empty => throw(Not_found) | Node(Empty, v, r, _) => v | Node(l, v, r, _) => min_elt(l) } let rec max_elt = x => switch x { - | Empty => raise(Not_found) + | Empty => throw(Not_found) | Node(l, v, Empty, _) => v | Node(l, v, r, _) => max_elt(r) } @@ -463,7 +463,7 @@ module Make = (Ord: OrderedType) => { let rec find = (x, x_) => switch x_ { - | Empty => raise(Not_found) + | Empty => throw(Not_found) | Node(l, v, r, _) => let c = Ord.compare(x, v) if c == 0 { diff --git a/tests/tests/src/test_static_catch_ident.res b/tests/tests/src/test_static_catch_ident.res index b893cb1ee4..b2ad8db721 100644 --- a/tests/tests/src/test_static_catch_ident.res +++ b/tests/tests/src/test_static_catch_ident.res @@ -7,5 +7,5 @@ let scanf_bad_input = (ib, x) => Js.log(s) /* necessary */ Js.log("don't inlinie") } - | x => raise(x) + | x => throw(x) } diff --git a/tests/tests/src/test_trywith.res b/tests/tests/src/test_trywith.res index 271fc25bbc..3bc6206f3b 100644 --- a/tests/tests/src/test_trywith.res +++ b/tests/tests/src/test_trywith.res @@ -39,7 +39,7 @@ let ff = (g, x) => { @@warning("-21") let u = () => { - raise(Not_found) + throw(Not_found) let f = 3 + 3 f + f } diff --git a/tests/tests/src/topsort_test.res b/tests/tests/src/topsort_test.res index 6877d510d7..6dae48a9fb 100644 --- a/tests/tests/src/topsort_test.res +++ b/tests/tests/src/topsort_test.res @@ -121,7 +121,7 @@ let pathsort = graph => { let empty_path = (String_set.empty, list{}) let \"+>" = (node, (set, stack)) => if String_set.has(set, node) { - raise(Cycle(list{node, ...stack})) + throw(Cycle(list{node, ...stack})) } else { (String_set.add(set, node), list{node, ...stack}) } diff --git a/tests/tests/src/uncurried_cast.res b/tests/tests/src/uncurried_cast.res index 95b7488120..f7244ec081 100644 --- a/tests/tests/src/uncurried_cast.res +++ b/tests/tests/src/uncurried_cast.res @@ -1,5 +1,5 @@ module Uncurried = { - let raise = e => raise(e) + let raise = e => throw(e) module List = { let map = (l, f) => Belt.List.map(l, f) @@ -11,7 +11,7 @@ exception E module StandardNotation = { open Uncurried - let testRaise = () => raise(E) + let testRaise = () => throw(E) let l = List.map(list{1, 2}, x => x + 1) let partial = x => List.map(list{1, 2}, x) @@ -23,7 +23,7 @@ module StandardNotation = { open Uncurried -let testRaise = () => raise(E) +let testRaise = () => throw(E) let l = List.map(list{1, 2}, x => x + 1) let partial = List.map(list{1, 2}, ...)