Opinionated OCaml linter with Merlin integration for code quality, naming conventions, and style checks
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix merlint parameter counting for functions returning tuples

core_type_to_string didn't wrap arrow types in parentheses when they
appeared inside tuples, so (unit -> unit) * (unit -> unit) rendered as
unit -> unit * unit -> unit. count_args then counted those bare arrows
as top-level parameters (6 instead of 4).

+15 -2
+3 -1
lib/docs.ml
··· 315 315 let result = label_prefix ^ arg_str ^ " -> " ^ ret_str in 316 316 if wrap_arrows then "(" ^ result ^ ")" else result 317 317 | Ptyp_tuple types -> 318 - let type_strs = List.map (fun (_, t) -> core_type_to_string t) types in 318 + let type_strs = 319 + List.map (fun (_, t) -> core_type_to_string ~wrap_arrows:true t) types 320 + in 319 321 String.concat " * " type_strs 320 322 | _ -> "<complex type>" 321 323
+12 -1
test/test_docs.ml
··· 55 55 "[field_codec name ?constraint_ typ ~get ~set] creates a field codec." 56 56 in 57 57 Alcotest.(check (list style_issue)) 58 - "function-typed args (arrows inside parens)" [] issues 58 + "function-typed args (arrows inside parens)" [] issues; 59 + 60 + (* Function returning a tuple of functions - arrows in return tuple should not count *) 61 + let issues = 62 + check_function_doc ~name:"cycling" 63 + ~signature: 64 + "data:bytes -> n_items:int -> size:int -> (bytes -> int -> unit) -> \ 65 + (unit -> unit) * (unit -> unit)" 66 + ~doc:"[cycling ~data ~n_items ~size read_fn] cycles through items." 67 + in 68 + Alcotest.(check (list style_issue)) 69 + "function returning tuple of functions" [] issues 59 70 60 71 let test_check_value_doc () = 61 72 let open Merlint.Docs in