• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Kakadu / zanuda / 39

18 Oct 2025 06:11PM UTC coverage: 86.625% (-0.03%) from 86.659%
39

push

github

Kakadu
[Fixes]: Don't crash when something goes wrong but raise exception

Signed-off-by: Kakadu <Kakadu@pm.me>

2 of 5 new or added lines in 1 file covered. (40.0%)

2215 of 2557 relevant lines covered (86.62%)

525.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.73
/src/fix/refactoring/Propose_function.ml
1
[@@@ocaml.text "/*"]
2

3
(** Copyright 2021-2025, Kakadu. *)
4

5
(** SPDX-License-Identifier: LGPL-3.0-or-later *)
6

7
[@@@ocaml.text "/*"]
8

9
open Tast_pattern
10
open Utils
11
open Typedtree
12

13
exception Fix_error of Warnings.loc * string
14

15
let first_case ~loc = function
16
  | h :: _ -> h
7✔
NEW
17
  | [] -> raise (Fix_error (loc, "Can't match cases"))
×
18
;;
19

20
let get_match_constr_payload loc ematch_cases =
21
  let pat =
7✔
22
    let c = first_case ~loc ematch_cases in
23
    c.c_lhs
7✔
24
  in
25
  let point = Utils.{ loc; pos = Start } in
26
  let shift_point = shift_point_cnum point 5 in
27
  set_padding shift_point (pat_point pat Start) Space_padding;
7✔
28
  set_padding point shift_point (Padding "function")
7✔
29
;;
30

31
let get_propose_function_payload loc =
32
  set_empty_padding (make_point loc Start) (make_point loc End)
7✔
33
;;
34

35
(* TODO(Kakadu): describe difference between two locations *)
36
let register_fix ~loc scru_pat_loc cases =
37
  (* Format.printf "%s: %a\n%!" __FUNCTION__ My_printtyped.expr e; *)
38
  (* Format.printf "loc = %a\n%!" Location.print_loc loc; *)
39
  try
7✔
40
    get_match_constr_payload loc cases;
41
    get_propose_function_payload scru_pat_loc
7✔
42
  with
NEW
43
  | Fix_error (loc, msg) ->
×
44
    Format.eprintf "Error at %s %d\n%!" __FILE__ __LINE__;
NEW
45
    Format.eprintf "While analyzing source at %a\n%!" Location.print_loc loc
×
46
;;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc