File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -348,7 +348,7 @@ let printPolyVarIdent txt =
348
348
| [] , [] -> Doc. nil
349
349
| labels , types ->
350
350
let i = ref 0 in
351
- let package = Doc. join ~sep: Doc. line (List. map2 (fun lbl typ ->
351
+ let package = Doc. join ~sep: Doc. line (( List. map2 [ @ doesNotRaise]) (fun lbl typ ->
352
352
Doc. concat [
353
353
Doc. text (if i.contents > 0 then " and " else " with " );
354
354
Doc. text lbl;
@@ -376,13 +376,21 @@ let printPolyVarIdent txt =
376
376
let (typArgs, typ) = collectArrowArgs typ [] in
377
377
let args = Doc. join ~sep: (Doc. concat [Doc. comma; Doc. line]) (
378
378
List. map (fun (lbl , typ ) ->
379
- if lbl = " " then
379
+ let lblLen = String. length lbl in
380
+ if lblLen = 0 then
380
381
printOutTypeDoc typ
381
382
else
383
+ let (lbl, optionalIndicator) =
384
+ (* the ocaml compiler hardcodes the optional label inside the string of the label in printtyp.ml *)
385
+ match String. unsafe_get lbl 0 with
386
+ | '?' -> ((String. sub [@ doesNotRaise]) lbl 1 (lblLen - 1 ) , Doc. text " =?" )
387
+ | _ -> (lbl, Doc. nil)
388
+ in
382
389
Doc. group (
383
390
Doc. concat [
384
391
Doc. text (" ~" ^ lbl ^ " : " );
385
- printOutTypeDoc typ
392
+ printOutTypeDoc typ;
393
+ optionalIndicator
386
394
]
387
395
)
388
396
) typArgs
Original file line number Diff line number Diff line change @@ -491,4 +491,5 @@ and ASet: {
491
491
let find_last_opt: (elt => bool, t) => option<elt>
492
492
let of_list: list<elt> => t
493
493
}
494
- type emptyObject = {.}
494
+ type emptyObject = {.}
495
+ let f: (~x: 'a=?, ~y: 'b) => option<'a>
Original file line number Diff line number Diff line change @@ -334,3 +334,5 @@ module rec A: {
334
334
and ASet : Set .S with type elt = A .t = Set .Make (A )
335
335
336
336
type emptyObject = {.}
337
+
338
+ let f = (~x = ?, ~y as _ ) => x
You can’t perform that action at this time.
0 commit comments