Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion analysis/src/codemod.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let transform_opt ~source ~pos ~debug ~typ ~hint =
let cases =
collect_patterns pattern
|> List.map (fun (p : Parsetree.pattern) ->
Ast_helper.Exp.case p (Type_utils.Codegen.mk_fail_with_exp ()))
Ast_helper.Exp.case p (Type_utils.Codegen.mk_todo_exp ()))
in
let result = ref None in
let mk_iterator ~pos ~result =
Expand Down
10 changes: 5 additions & 5 deletions analysis/src/type_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1035,10 +1035,10 @@ let rec context_path_from_core_type (core_type : Parsetree.core_type) =
| _ -> None

module Codegen = struct
let mk_fail_with_exp () =
Ast_helper.Exp.apply
(Ast_helper.Exp.ident {txt = Lident "failwith"; loc = Location.none})
[(Nolabel, Ast_helper.Exp.constant (Ast_helper.Const.string "TODO"))]
(* Placeholder body for generated cases: `%todo`, which compiles (with a
warning) and throws at runtime. *)
let mk_todo_exp () =
Ast_helper.Exp.extension ({txt = "todo"; loc = Location.none}, PStr [])

let mk_construct_pat ?payload name =
Ast_helper.Pat.construct
Expand Down Expand Up @@ -1160,7 +1160,7 @@ module Codegen = struct
Some
(patterns
|> List.map (fun (pat : Parsetree.pattern) ->
Ast_helper.Exp.case pat (mk_fail_with_exp ())))
Ast_helper.Exp.case pat (mk_todo_exp ())))
end

let get_module_path_relative_to_env ~debug ~(env : Query_env.t) ~env_from_item
Expand Down
1 change: 1 addition & 0 deletions changes/code-action-todo-placeholder.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fill cases added by the exhaustive-switch and add-missing-cases code actions with `%todo` instead of the removed `failwith("TODO")`.
2 changes: 1 addition & 1 deletion changes/deprecated-let-without-interface.fix.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Warn when another module uses a `@deprecated` `let` binding from a module without an interface file. As a result, `failwith` and `invalid_arg`, deprecated since v12, now emit their deprecation warning when used.
- Warn when another module uses a `@deprecated` `let` binding from a module without an interface file.
4 changes: 2 additions & 2 deletions tests/analysis_tests/tests/src/expected/Codemod.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Codemod AddMissingCasessrc/Codemod.res 3:10
switch (v1, v2) {
// ^c-a (#valid, #valid) | (#invalid, _)
| (#valid, #invalid) => ()
| (#valid, #valid) => failwith("TODO")
| (#invalid, _) => failwith("TODO")
| (#valid, #valid) => %todo
| (#invalid, _) => %todo
}

16 changes: 8 additions & 8 deletions tests/analysis_tests/tests/src/expected/ExhaustiveSwitch.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ TextDocumentEdit: ExhaustiveSwitch.res
newText:
<--here
switch x->getV {
| One => failwith("TODO")
| Two => failwith("TODO")
| Three(_) => failwith("TODO")
| One => %todo
| Two => %todo
| Three(_) => %todo
}

Xform src/ExhaustiveSwitch.res 36:4
Expand All @@ -152,11 +152,11 @@ TextDocumentEdit: ExhaustiveSwitch.res
newText:
<--here
switch vvv {
| None => failwith("TODO")
| Some(_) => failwith("TODO")
| Some(One) => failwith("TODO")
| Some(Two) => failwith("TODO")
| Some(Three(_)) => failwith("TODO")
| None => %todo
| Some(_) => %todo
| Some(One) => %todo
| Some(Two) => %todo
| Some(Three(_)) => %todo
}


Expand Down
Loading