Skip to content

Commit 4efb406

Browse files
committed
Better handling of error in fix for #1001
1 parent 2d7dd9e commit 4efb406

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/document/generator.ml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ let tag tag t = O.span ~attr:tag t
2626
let label t =
2727
match t with
2828
| Odoc_model.Lang.TypeExpr.Label s -> tag "label" (O.txt s)
29-
| RawOptional _s ->
30-
tag "error" (O.txt "Error: RawOptional found during rendering")
31-
| Optional s -> tag "optlabel" (O.txt "?" ++ O.txt s)
29+
| Optional s | RawOptional s -> tag "optlabel" (O.txt "?" ++ O.txt s)
3230

3331
let type_var tv = tag "type-var" (O.txt tv)
3432

@@ -426,7 +424,14 @@ module Make (Syntax : SYNTAX) = struct
426424
if not needs_parentheses then res else enclose ~l:"(" res ~r:")"
427425
| Arrow (Some lbl, src, dst) ->
428426
let res =
429-
O.span
427+
match lbl with
428+
| RawOptional _ ->
429+
O.span
430+
((O.box_hv
431+
@@ label lbl ++ O.txt ":" ++ tag "error" (O.txt "???")
432+
++ O.txt " " ++ Syntax.Type.arrow))
433+
++ O.sp ++ type_expr dst
434+
| _ -> O.span
430435
((O.box_hv
431436
@@ label lbl ++ O.txt ":" ++ O.cut
432437
++ (O.box_hv @@ type_expr ~needs_parentheses:true src))
@@ -1089,7 +1094,13 @@ module Make (Syntax : SYNTAX) = struct
10891094
(type_expr ~needs_parentheses:true src
10901095
++ O.txt " " ++ Syntax.Type.arrow)
10911096
++ O.txt " " ++ class_decl dst
1092-
| Arrow (Some lbl, src, dst) ->
1097+
| Arrow (Some (RawOptional _ as lbl), _src, dst) ->
1098+
O.span
1099+
((O.box_hv
1100+
@@ label lbl ++ O.txt ":" ++ tag "error" (O.txt "???")
1101+
++ O.txt " " ++ Syntax.Type.arrow))
1102+
++ O.sp ++ class_decl dst
1103+
| Arrow (Some lbl , src, dst) ->
10931104
O.span
10941105
(label lbl ++ O.txt ":"
10951106
++ type_expr ~needs_parentheses:true src

0 commit comments

Comments
 (0)