123456789101112131415161718192021222324252627282930openStdLabelsopenMigrate_parsetreeopenOCaml_406.Astopen!Ast_mapperopenAst_helperopenAsttypesopenParsetreeopen!Ast_convenience_406moduleAst_mapper=structletextension_of_error({kind;main;sub}:Location.error)=ifkind<>Location.Report_errorthenraise(Invalid_argument"extension_of_error: expected kind Report_error");letstr_of_pppp_msg=Format.asprintf"%t"pp_msginletextension_of_sub(sub:Location.msg)=({Location.loc=sub.loc;txt="ocaml.error"},Parsetree.(PStr[Str.eval(Exp.constant(Pconst_string(str_of_ppsub.txt,None)))]))in(* Remove the duplicated error bellow once switching to Ast 4.08 *)({loc=main.loc;txt="ocaml.error"},PStr(Str.eval(Exp.constant(Pconst_string(str_of_ppmain.txt,None)))::Str.eval(Exp.constant(Pconst_string(str_of_ppmain.txt,None)))::List.map~f:(funmsg->Str.extension(extension_of_submsg))sub))endmoduleLocation=structletmsg=Location.msgend