@@ -275,7 +275,7 @@ struct
275275 location : Location .t ;
276276 value : string ;
277277 format : string ;
278- labels : string list ;
278+ labels : string list option ;
279279 }
280280 [@@ deriving eq , ord , hash ]
281281
@@ -286,15 +286,18 @@ struct
286286 (" location" , Location. to_yaml location);
287287 (" value" , `String value);
288288 (" format" , `String format);
289- (" labels" , `A (List. map (fun label -> `String label) labels));
290- ]
289+ ] @ match labels with
290+ | Some labels -> [
291+ (" labels" , `A (List. map (fun label -> `String label) labels));
292+ ]
293+ | None -> []
291294
292295 let of_yaml y =
293296 let open GobYaml in
294297 let + location = y |> find " location" >> = Location. of_yaml
295298 and + value = y |> find " value" >> = to_string
296299 and + format = y |> find " format" >> = to_string
297- and + labels = y |> find " labels" >> = list >> = list_map to_string in
300+ and + labels = y |> Yaml.Util. find " labels" >> = option_map ( fun y -> y |> list >> = list_map to_string) in
298301 {location; value; format; labels}
299302 end
300303
@@ -390,7 +393,7 @@ struct
390393 requires : string ;
391394 ensures : string ;
392395 format : string ;
393- labels : string list ;
396+ labels : string list option ;
394397 }
395398 [@@ deriving eq , ord , hash ]
396399
@@ -402,16 +405,19 @@ struct
402405 (" requires" , `String requires);
403406 (" ensures" , `String ensures);
404407 (" format" , `String format);
405- (" labels" , `A (List. map (fun label -> `String label) labels));
406- ]
408+ ] @ match labels with
409+ | Some labels -> [
410+ (" labels" , `A (List. map (fun label -> `String label) labels));
411+ ]
412+ | None -> []
407413
408414 let of_yaml y =
409415 let open GobYaml in
410416 let + location = y |> find " location" >> = Location. of_yaml
411417 and + requires = y |> find " requires" >> = to_string
412418 and + ensures = y |> find " ensures" >> = to_string
413419 and + format = y |> find " format" >> = to_string
414- and + labels = y |> find " labels" >> = list >> = list_map to_string in
420+ and + labels = y |> Yaml.Util. find " labels" >> = option_map ( fun y -> y |> list >> = list_map to_string) in
415421 {location; requires; ensures; format; labels}
416422 end
417423
0 commit comments