123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870open!Importletpoly_equalab=letmodulePoly=structtypet=T:_->tendinStdppx.Poly.equal(Poly.Ta)(Poly.Tb)moduleContext=structtype'at=|Label_declaration:label_declarationt|Constructor_declaration:constructor_declarationt|Type_declaration:type_declarationt|Type_exception:type_exceptiont|Type_extension:type_extensiont|Extension_constructor:extension_constructort|Pattern:patternt|Core_type:core_typet|Expression:expressiont|Value_description:value_descriptiont|Class_type:class_typet|Class_type_field:class_type_fieldt|Class_infos:_class_infost|Class_expr:class_exprt|Class_field:class_fieldt|Class_type_decl:class_type_declarationt|Module_type:module_typet|Module_declaration:module_declarationt|Module_type_declaration:module_type_declarationt|Module_substitution:module_substitutiont|Open_description:open_descriptiont|Open_declaration:open_declarationt|Include_infos:_include_infost|Module_expr:module_exprt|Value_binding:value_bindingt|Module_binding:module_bindingt|Pstr_eval:structure_itemt|Pstr_extension:structure_itemt|Psig_extension:signature_itemt|Rtag:row_fieldt|Object_type_field:object_fieldtletlabel_declaration=Label_declarationletconstructor_declaration=Constructor_declarationlettype_declaration=Type_declarationlettype_extension=Type_extensionlettype_exception=Type_exceptionletextension_constructor=Extension_constructorletpattern=Patternletcore_type=Core_typeletexpression=Expressionletvalue_description=Value_descriptionletclass_type=Class_typeletclass_type_field=Class_type_fieldletclass_infos=Class_infosletclass_expr=Class_exprletclass_field=Class_fieldletclass_type_decl=Class_type_declletmodule_type=Module_typeletmodule_declaration=Module_declarationletmodule_type_declaration=Module_type_declarationletopen_description=Open_descriptionletinclude_infos=Include_infosletmodule_expr=Module_exprletvalue_binding=Value_bindingletmodule_binding=Module_bindingletpstr_eval=Pstr_evalletpstr_extension=Pstr_extensionletpsig_extension=Psig_extensionletrtag=Rtagletobject_type_field=Object_type_fieldletget_pstr_evalst=matchst.pstr_descwith|Pstr_eval(e,l)->(e,l)|_->failwith"Attribute.Context.get_pstr_eval"letget_pstr_extensionst=matchst.pstr_descwith|Pstr_extension(e,l)->(e,l)|_->failwith"Attribute.Context.get_pstr_extension"letget_psig_extensionst=matchst.psig_descwith|Psig_extension(e,l)->(e,l)|_->failwith"Attribute.Context.get_psig_extension"letget_attributes:typea.at->a->attributes=funtx->matchtwith|Label_declaration->x.pld_attributes|Constructor_declaration->x.pcd_attributes|Type_declaration->x.ptype_attributes|Type_extension->x.ptyext_attributes|Type_exception->x.ptyexn_attributes|Extension_constructor->x.pext_attributes|Pattern->x.ppat_attributes|Core_type->x.ptyp_attributes|Expression->x.pexp_attributes|Value_description->x.pval_attributes|Class_type->x.pcty_attributes|Class_type_field->x.pctf_attributes|Class_infos->x.pci_attributes|Class_expr->x.pcl_attributes|Class_field->x.pcf_attributes|Class_type_decl->x.pci_attributes|Module_type->x.pmty_attributes|Module_declaration->x.pmd_attributes|Module_type_declaration->x.pmtd_attributes|Module_substitution->x.pms_attributes|Open_description->x.popen_attributes|Open_declaration->x.popen_attributes|Include_infos->x.pincl_attributes|Module_expr->x.pmod_attributes|Value_binding->x.pvb_attributes|Module_binding->x.pmb_attributes|Pstr_eval->snd(get_pstr_evalx)|Pstr_extension->snd(get_pstr_extensionx)|Psig_extension->snd(get_psig_extensionx)|Rtag->x.prf_attributes|Object_type_field->x.pof_attributesletset_attributes:typea.at->a->attributes->a=funtxattrs->matchtwith|Label_declaration->{xwithpld_attributes=attrs}|Constructor_declaration->{xwithpcd_attributes=attrs}|Type_declaration->{xwithptype_attributes=attrs}|Type_extension->{xwithptyext_attributes=attrs}|Type_exception->{xwithptyexn_attributes=attrs}|Extension_constructor->{xwithpext_attributes=attrs}|Pattern->{xwithppat_attributes=attrs}|Core_type->{xwithptyp_attributes=attrs}|Expression->{xwithpexp_attributes=attrs}|Value_description->{xwithpval_attributes=attrs}|Class_type->{xwithpcty_attributes=attrs}|Class_type_field->{xwithpctf_attributes=attrs}|Class_infos->{xwithpci_attributes=attrs}|Class_expr->{xwithpcl_attributes=attrs}|Class_field->{xwithpcf_attributes=attrs}|Class_type_decl->{xwithpci_attributes=attrs}|Module_type->{xwithpmty_attributes=attrs}|Module_declaration->{xwithpmd_attributes=attrs}|Module_type_declaration->{xwithpmtd_attributes=attrs}|Module_substitution->{xwithpms_attributes=attrs}|Open_description->{xwithpopen_attributes=attrs}|Open_declaration->{xwithpopen_attributes=attrs}|Include_infos->{xwithpincl_attributes=attrs}|Module_expr->{xwithpmod_attributes=attrs}|Value_binding->{xwithpvb_attributes=attrs}|Module_binding->{xwithpmb_attributes=attrs}|Pstr_eval->{xwithpstr_desc=Pstr_eval(get_pstr_evalx|>fst,attrs)}|Pstr_extension->{xwithpstr_desc=Pstr_extension(get_pstr_extensionx|>fst,attrs);}|Psig_extension->{xwithpsig_desc=Psig_extension(get_psig_extensionx|>fst,attrs);}|Rtag->{xwithprf_attributes=attrs}|Object_type_field->{xwithpof_attributes=attrs}letdesc:typea.at->string=function|Label_declaration->"label declaration"|Constructor_declaration->"constructor declaration"|Type_declaration->"type declaration"|Type_extension->"type extension"|Type_exception->"type exception"|Extension_constructor->"extension constructor"|Pattern->"pattern"|Core_type->"core type"|Expression->"expression"|Value_description->"value"|Class_type->"class type"|Class_type_field->"class type field"|Class_infos->"class declaration"|Class_expr->"class expression"|Class_field->"class field"|Class_type_decl->"class type declaration"|Module_type->"module type"|Module_declaration->"module declaration"|Module_type_declaration->"module type declaration"|Module_substitution->"module substitution"|Open_description->"open"|Open_declaration->"open"|Include_infos->"include"|Module_expr->"module expression"|Value_binding->"value binding"|Module_binding->"module binding"|Pstr_eval->"toplevel expression"|Pstr_extension->"toplevel extension"|Psig_extension->"toplevel signature extension"|Rtag->"polymorphic variant tag"|Object_type_field->"object type field"(*
let pattern : type a b c d. a t
-> (attributes, b, c) Ast_pattern.t
-> (a, c, d) Ast_pattern.t
-> (a, b, d) Ast_pattern.t = function
| Label_declaration -> Ast_pattern.pld_attributes
| Constructor_declaration -> Ast_pattern.pcd_attributes
| Type_declaration -> Ast_pattern.ptype_attributes
| Type_extension -> Ast_pattern.ptyext_attributes
| Extension_constructor -> Ast_pattern.pext_attributes
*)letequal:_t->_t->bool=poly_equalendmoduleFloating_context=structtype'at=|Structure_item:structure_itemt|Signature_item:signature_itemt|Class_field:class_fieldt|Class_type_field:class_type_fieldtletstructure_item=Structure_itemletsignature_item=Signature_itemletclass_field=Class_fieldletclass_type_field=Class_type_fieldletget_attribute_if_is_floating_node:typea.at->a->attributeoption=funtx->match(t,x)with|Structure_item,{pstr_desc=Pstr_attributea;_}->Somea|Signature_item,{psig_desc=Psig_attributea;_}->Somea|Class_field,{pcf_desc=Pcf_attributea;_}->Somea|Class_type_field,{pctf_desc=Pctf_attributea;_}->Somea|_->Noneletget_attributetx=matchget_attribute_if_is_floating_nodetxwith|Somea->a|None->failwith"Attribute.Floating.Context.get_attribute"letreplace_by_dummy:typea.at->a->a=letdummy_ext=({txt="";loc=Location.none},PStr[])infuntx->matchtwith|Structure_item->{xwithpstr_desc=Pstr_extension(dummy_ext,[])}|Signature_item->{xwithpsig_desc=Psig_extension(dummy_ext,[])}|Class_field->{xwithpcf_desc=Pcf_extensiondummy_ext}|Class_type_field->{xwithpctf_desc=Pctf_extensiondummy_ext}letdesc:typea.at->string=function|Structure_item->"structure item"|Signature_item->"signature item"|Class_field->"class field"|Class_type_field->"class type field"letequal:_t->_t->bool=poly_equalendtypepacked_context=|On_item:_Context.t->packed_context|Floating:_Floating_context.t->packed_contexttype_payload_parser=|Payload_parser:(payload,'a,'b)Ast_pattern.t*(attr_loc:Location.t->name_loc:Location.t->'a)->'bpayload_parsertype('a,'b)t={name:Name.Pattern.t;context:'aContext.t;payload:'bpayload_parser;}typepacked=T:(_,_)t->packedletnamet=Name.Pattern.namet.nameletcontextt=t.contextletregistrar=Name.Registrar.create~kind:"attribute"~current_file:__FILE__~string_of_context:(function|On_itemt->Some(Context.desct)|Floatingt->Some(Floating_context.desct^" (floating)"))letdeclare_with_all_argsnamecontextpatternk=Name.Registrar.register~kind:`Attributeregistrar(On_itemcontext)name;{name=Name.Pattern.makename;context;payload=Payload_parser(pattern,k);}letdeclarenamecontextpatternk=declare_with_all_argsnamecontextpattern(fun~attr_loc:_~name_loc:_->k)letdeclare_with_name_locnamecontextpatternk=declare_with_all_argsnamecontextpattern(fun~attr_loc:_~name_loc->k~name_loc)letdeclare_with_attr_locnamecontextpatternk=declare_with_all_argsnamecontextpattern(fun~attr_loc~name_loc:_->k~attr_loc)type'aflag=('a,unit)tletdeclare_flagnamecontext=letpayload_pattern=Ast_pattern.(pstrnil)inletcontinuation~attr_loc:_~name_loc:_=()indeclare_with_all_argsnamecontextpayload_patterncontinuationmoduleAttribute_table=Stdlib.Hashtbl.Make(structtypet=stringlocletnormalizet={twithloc={t.locwithloc_ghost=true}}lethasht=Hashtbl.hash(normalizet)letequalxy=Poly.equal(normalizex)(normalizey)end)letnot_seen=Attribute_table.create128letmark_as_seen{attr_name;_}=Attribute_table.removenot_seenattr_nameletmark_as_handled_manually=mark_as_seenletexplicitly_drop=objectinheritAst_traverse0.itermethod!attribute=mark_as_seenendletget_internal=letrecfind_best_matchtattributeslongest_match=matchattributeswith|[]->Oklongest_match|({attr_name=name;_}asattr)::rest->ifName.Pattern.matchest.namename.txtthenmatchlongest_matchwith|None->find_best_matchtrest(Someattr)|Some{attr_name=name';_}->letlen=String.lengthname.txtinletlen'=String.lengthname'.txtiniflen>len'thenfind_best_matchtrest(Someattr)elseiflen<len'thenfind_best_matchtrestlongest_matchelseError(Location.Error.createf~loc:name.loc"Duplicated attribute",[])elsefind_best_matchtrestlongest_matchinfuntattributes->find_best_matchtattributesNoneletconvert?(do_mark_as_seen=true)patternattr=ifdo_mark_as_seenthenmark_as_seenattr;let(Payload_parser(pattern,k))=patterninAst_pattern.parse_respattern(Common.loc_of_payloadattr)attr.attr_payload(k~attr_loc:attr.attr_loc~name_loc:attr.attr_name.loc)letget_rest?mark_as_seen:do_mark_as_seenx=letopenResultinletattrs=Context.get_attributest.contextxinget_internaltattrs>>=funres->matchreswith|None->OkNone|Someattr->convertt.payloadattr?do_mark_as_seen>>|funvalue->Somevalueletgett?mark_as_seen:do_mark_as_seenx=get_rest?mark_as_seen:do_mark_as_seenx|>Result.handle_error~f:(fun(err,_)->Location.Error.raiseerr)lethas_flag_rest?mark_as_seenx=matchget_res?mark_as_seentxwith|Ok(Some())->Oktrue|OkNone->Okfalse|Error_ase->elethas_flagt?mark_as_seenx=has_flag_rest?mark_as_seenx|>Result.handle_error~f:(fun(err,_)->Location.Error.raiseerr)letconsume_restx=letopenResultinletattrs=Context.get_attributest.contextxinget_internaltattrs>>=funres->matchreswith|None->OkNone|Someattr->letattrs=List.filterattrs~f:(funattr'->not(attr==attr'))inletx=Context.set_attributest.contextxattrsinconvertt.payloadattr>>|funvalue->Some(x,value)letconsumetx=consume_restx|>Result.handle_error~f:(fun(err,_)->Location.Error.raiseerr)letremove_seen_res(typea)(context:aContext.t)packeds(x:a)=letopenResultinletattrs=Context.get_attributescontextxinletrecloopacc=function|[]->Okacc|Tt::rest->ifContext.equalt.contextcontextthenget_internaltattrs>>=funres->matchreswith|None->loopaccrest|Someattr->letname=attr.attr_nameinifAttribute_table.memnot_seennamethenloopaccrestelseloop(attr::acc)restelseloopaccrestinloop[]packeds>>|funmatched->letattrs=List.filterattrs~f:(funattr'->not(List.memq~set:matchedattr'))inContext.set_attributescontextxattrsletremove_seen(typea)(context:aContext.t)packeds(x:a)=remove_seen_res(context:aContext.t)packeds(x:a)|>Result.handle_error~f:(fun(err,_)->Location.Error.raiseerr)letpattern_restp=letopenResultinletf=Ast_pattern.to_funcpinAst_pattern.of_func(functxlocxk->consume_restx>>|funres->matchreswith|None->fctxlocx(kNone)|Some(x,v)->fctxlocx(k(Somev)))letpatterntp=pattern_restp|>Ast_pattern.to_func|>(funfabcd->fabcd|>Result.handle_error~f:(fun(err,_)->Location.Error.raiseerr))|>Ast_pattern.of_funcmoduleFloating=structmoduleContext=Floating_contexttype('a,'b)t={name:Name.Pattern.t;context:'aContext.t;payload:'bpayload_parser;}letnamet=Name.Pattern.namet.nameletdeclarenamecontextpatternk=Name.Registrar.register~kind:`Attributeregistrar(Floatingcontext)name;{name=Name.Pattern.makename;context;payload=Payload_parser(pattern,fun~attr_loc:_~name_loc:_->k);}letconvert_attr_restattr=letopenResultinifName.Pattern.matchest.nameattr.attr_name.txtthenconvertt.payloadattr>>|funvalue->SomevalueelseOkNoneletconvert_restsx=letopenResultinmatchtswith|[]->OkNone|{context;_}::_->(assert(List.for_allts~f:(funt->Context.equalt.contextcontext));letattr=Context.get_attributecontextxinletname=attr.attr_nameinmatchList.filterts~f:(funt->Name.Pattern.matchest.namename.txt)with|[]->OkNone|[t]->convertt.payloadattr>>|funvalue->Somevalue|l->Error(Location.Error.createf~loc:name.loc"Multiple match for floating attributes: %s"(String.concat~sep:", "(List.mapl~f:(funt->Name.Pattern.namet.name))),[]))letconverttsx=convert_restsx|>Result.handle_error~f:(fun(err,_)->Location.Error.raiseerr)endletcollect_attribute_errorsregistrarcontextname=if(not(Name.Allowlisted.is_allowlisted~kind:`Attributename.txt||Name.ignore_checksname.txt))&&Attribute_table.memnot_seennamethenletallowlist=Name.Allowlisted.get_attribute_list()in[Name.Registrar.Error.createfregistrarcontext~allowlist"Attribute `%s' was not used"name;]else[]letcollect_unused_attributes_errors=object(self)inherit[Location.Error.tlist]Ast_traverse0.foldassupermethod!attribute{attr_name=name;_}_=[Location.Error.createf~loc:name.loc"attribute not expected here, Ppxlib.Attribute needs updating!";]methodprivatecheck_node:typea.aContext.t->a->a*Location.Error.tlist=funcontextnode->letattrs=Context.get_attributescontextnodeinmatchattrswith|[]->(node,[])|_->leterrors=List.mapattrs~f:(fun({attr_name=name;attr_payload=payload;_}asattr)->letcollected_errors=self#payloadpayload[]@collect_attribute_errorsregistrar(On_itemcontext)namein(* If we allow the attribute to pass through, mark it as seen *)mark_as_seenattr;collected_errors)|>List.concatin(Context.set_attributescontextnode[],errors)methodprivatecheck_floating:typea.aFloating.Context.t->a->a*Location.Error.tlist=funcontextnode->matchFloating.Context.get_attribute_if_is_floating_nodecontextnodewith|None->(node,[])|Some({attr_name=name;attr_payload=payload;_}asattr)->letcollected_errors=self#payloadpayload[]@collect_attribute_errorsregistrar(Floatingcontext)nameinmark_as_seenattr;(Floating.Context.replace_by_dummycontextnode,collected_errors)method!label_declarationxacc=letres,errors=self#check_nodeLabel_declarationxinsuper#label_declarationres(acc@errors)method!constructor_declarationxacc=letres,errors=self#check_nodeConstructor_declarationxinsuper#constructor_declarationres(acc@errors)method!type_declarationxacc=letres,errors=self#check_nodeType_declarationxinsuper#type_declarationres(acc@errors)method!type_extensionxacc=letres,errors=self#check_nodeType_extensionxinsuper#type_extensionres(acc@errors)method!type_exceptionxacc=letres,errors=self#check_nodeType_exceptionxinsuper#type_exceptionres(acc@errors)method!extension_constructorxacc=letres,errors=self#check_nodeExtension_constructorxinsuper#extension_constructorres(acc@errors)method!patternxacc=letres,errors=self#check_nodePatternxinsuper#patternres(acc@errors)method!core_typexacc=letres,errors=self#check_nodeCore_typexinsuper#core_typeres(acc@errors)method!expressionxacc=letres,errors=self#check_nodeExpressionxinsuper#expressionres(acc@errors)method!value_descriptionxacc=letres,errors=self#check_nodeValue_descriptionxinsuper#value_descriptionres(acc@errors)method!class_typexacc=letres,errors=self#check_nodeClass_typexinsuper#class_typeres(acc@errors)method!class_infosfxacc=letres,errors=self#check_nodeClass_infosxinsuper#class_infosfres(acc@errors)method!class_exprxacc=letres,errors=self#check_nodeClass_exprxinsuper#class_exprres(acc@errors)method!module_typexacc=letres,errors=self#check_nodeModule_typexinsuper#module_typeres(acc@errors)method!module_declarationxacc=letres,errors=self#check_nodeModule_declarationxinsuper#module_declarationres(acc@errors)method!module_type_declarationxacc=letres,errors=self#check_nodeModule_type_declarationxinsuper#module_type_declarationres(acc@errors)method!open_descriptionxacc=letres,errors=self#check_nodeOpen_descriptionxinsuper#open_descriptionres(acc@errors)method!open_declarationxacc=letres,errors=self#check_nodeOpen_declarationxinsuper#open_declarationres(acc@errors)method!include_infosfxacc=letres,errors=self#check_nodeInclude_infosxinsuper#include_infosfres(acc@errors)method!module_exprxacc=letres,errors=self#check_nodeModule_exprxinsuper#module_exprres(acc@errors)method!value_bindingxacc=letres,errors=self#check_nodeValue_bindingxinsuper#value_bindingres(acc@errors)method!module_bindingxacc=letres,errors=self#check_nodeModule_bindingxinsuper#module_bindingres(acc@errors)method!class_fieldxacc=letx,errors1=self#check_nodeClass_fieldxinletx,errors2=self#check_floatingClass_fieldxinsuper#class_fieldx(acc@errors1@errors2)method!class_type_fieldxacc=letx,errors1=self#check_nodeClass_type_fieldxinletx,errors2=self#check_floatingClass_type_fieldxinsuper#class_type_fieldx(acc@errors1@errors2)method!row_fieldxacc=letx,errors=matchx.prf_descwithRtag_->self#check_nodeRtagx|_->(x,[])insuper#row_fieldx(acc@errors)method!core_type_descxacc=letx,errors=matchxwith|Ptyp_object(fields,closed_flag)->letfields,errors=List.mapfields~f:(self#check_nodeObject_type_field)|>List.splitin(Ptyp_object(fields,closed_flag),List.concaterrors)|_->(x,[])insuper#core_type_descx(acc@errors)method!structure_itemitemacc=letitem,errors=self#check_floatingStructure_itemiteminletitem,errors2=matchitem.pstr_descwith|Pstr_eval_->self#check_nodePstr_evalitem|Pstr_extension_->self#check_nodePstr_extensionitem|_->(item,[])insuper#structure_itemitem(acc@errors@errors2)method!signature_itemitemacc=letitem,errors=self#check_floatingSignature_itemiteminletitem,errors2=matchitem.psig_descwith|Psig_extension_->self#check_nodePsig_extensionitem|_->(item,[])insuper#signature_itemitem(acc@errors@errors2)endletcheck_attributeregistrarcontextname=matchcollect_attribute_errorsregistrarcontextnamewith|[]->()|err::_->Location.Error.raiseerrletraise_if_non_empty=function|[]->()|err::_->Location.Error.raiseerrletcheck_unused=object(self)inheritAst_traverse0.iterassupermethodprivatecheck_node:typea.aContext.t->a->a=funcontextnode->letattrs=Context.get_attributescontextnodeinmatchattrswith|[]->node|_->List.iterattrs~f:(fun({attr_name=name;attr_payload=payload;_}asattr)->self#payloadpayload;check_attributeregistrar(On_itemcontext)name;(* If we allow the attribute to pass through, mark it as seen *)mark_as_seenattr);Context.set_attributescontextnode[]method!attribute{attr_name=name;_}=Location.raise_errorf~loc:name.loc"attribute not expected here, Ppxlib.Attribute needs updating!"method!label_declarationx=collect_unused_attributes_errors#label_declarationx[]|>raise_if_non_emptymethod!constructor_declarationx=collect_unused_attributes_errors#constructor_declarationx[]|>raise_if_non_emptymethod!type_declarationx=collect_unused_attributes_errors#type_declarationx[]|>raise_if_non_emptymethod!type_extensionx=collect_unused_attributes_errors#type_extensionx[]|>raise_if_non_emptymethod!type_exceptionx=collect_unused_attributes_errors#type_exceptionx[]|>raise_if_non_emptymethod!extension_constructorx=collect_unused_attributes_errors#extension_constructorx[]|>raise_if_non_emptymethod!patternx=collect_unused_attributes_errors#patternx[]|>raise_if_non_emptymethod!core_typex=collect_unused_attributes_errors#core_typex[]|>raise_if_non_emptymethod!expressionx=collect_unused_attributes_errors#expressionx[]|>raise_if_non_emptymethod!value_descriptionx=collect_unused_attributes_errors#value_descriptionx[]|>raise_if_non_emptymethod!class_typex=collect_unused_attributes_errors#class_typex[]|>raise_if_non_emptymethod!class_infosfx=super#class_infosf(self#check_nodeClass_infosx)method!class_exprx=collect_unused_attributes_errors#class_exprx[]|>raise_if_non_emptymethod!module_typex=collect_unused_attributes_errors#module_typex[]|>raise_if_non_emptymethod!module_declarationx=collect_unused_attributes_errors#module_declarationx[]|>raise_if_non_emptymethod!module_type_declarationx=collect_unused_attributes_errors#module_type_declarationx[]|>raise_if_non_emptymethod!open_descriptionx=collect_unused_attributes_errors#open_descriptionx[]|>raise_if_non_emptymethod!open_declarationx=collect_unused_attributes_errors#open_declarationx[]|>raise_if_non_emptymethod!include_infosfx=super#include_infosf(self#check_nodeInclude_infosx)method!module_exprx=collect_unused_attributes_errors#module_exprx[]|>raise_if_non_emptymethod!value_bindingx=collect_unused_attributes_errors#value_bindingx[]|>raise_if_non_emptymethod!module_bindingx=collect_unused_attributes_errors#module_bindingx[]|>raise_if_non_emptymethod!class_fieldx=collect_unused_attributes_errors#class_fieldx[]|>raise_if_non_emptymethod!class_type_fieldx=collect_unused_attributes_errors#class_type_fieldx[]|>raise_if_non_emptymethod!row_fieldx=collect_unused_attributes_errors#row_fieldx[]|>raise_if_non_emptymethod!core_type_descx=collect_unused_attributes_errors#core_type_descx[]|>raise_if_non_emptymethod!structure_itemitem=collect_unused_attributes_errors#structure_itemitem[]|>raise_if_non_emptymethod!signature_itemitem=collect_unused_attributes_errors#signature_itemitem[]|>raise_if_non_emptyendletreset_checks()=Attribute_table.clearnot_seenletcollect=objectinheritAst_traverse0.iterassupermethod!attribute({attr_name=name;attr_payload=payload;_}asattr)=letloc=Common.loc_of_attributeattrinsuper#payloadpayload;Attribute_table.addnot_seennamelocendletcollect_unseen_errors()=letfailnamelocacc=lettxt=name.txtinifnot(Name.ignore_checkstxt)thenLocation.Error.createf~loc"Attribute `%s' was silently dropped"txt::accelseaccinAttribute_table.foldfailnot_seen[]letcheck_all_seen()=matchcollect_unseen_errors()with|[]->()|err::_->Location.Error.raiseerrletremove_attributes_present_intable=objectinheritAst_traverse0.iterassupermethod!attribute{attr_name=name;attr_payload=payload;_}=super#payloadpayload;Attribute_table.removetablenameendletcopy_of_not_seen()=letcopy=Attribute_table.create(Attribute_table.lengthnot_seen)inAttribute_table.iter(Attribute_table.addcopy)not_seen;copyletdropped_so_far_structurest=lettable=copy_of_not_seen()in(remove_attributes_present_intable)#structurest;Attribute_table.fold(funnamelocacc->{txt=name.txt;loc}::acc)table[]letdropped_so_far_signaturesg=lettable=copy_of_not_seen()in(remove_attributes_present_intable)#signaturesg;Attribute_table.fold(funnamelocacc->{txt=name.txt;loc}::acc)table[]