@@ -181,6 +181,8 @@ let pr_attributes _ _ _ atts =
181181
182182let wit_elpi_ftactic_arg = EA.Tac.wit
183183
184+ let binders = Pcoq.Constr.binders
185+
184186let def_body = G_vernac.def_body
185187
186188let of_coq_inductive_declaration ~atts kind id =
@@ -195,12 +197,23 @@ let of_coq_record_declaration ~atts kind id =
195197 | Inductive _ -> assert false
196198 | Record r -> r
197199
198- let of_coq_definition ~loc ~atts name udecl def =
200+ [%%if coq = "8.20"]
201+ let of_coq_definition ~loc ~atts name udecl bl def =
202+ match def with
203+ | Vernacexpr.DefineBody(bl',red,c,ty) ->
204+ (* For compatibility with Coq PR #19301, binders have been parsed in advance *)
205+ assert (CList.is_empty bl');
206+ EA.Cmd.(ConstantDecl { name = snd name; atts; udecl; typ = (bl,ty); red; body = Some c })
207+ | Vernacexpr.ProveBody _ ->
208+ CErrors.user_err ~loc Pp.(str"syntax error: missing Definition body")
209+ [%%else]
210+ let of_coq_definition ~loc ~atts name udecl bl def =
199211 match def with
200- | Vernacexpr.DefineBody(bl, red,c,ty) ->
212+ | Vernacexpr.DefineBody(red,c,ty) ->
201213 EA.Cmd.(ConstantDecl { name = snd name; atts; udecl; typ = (bl,ty); red; body = Some c })
202214 | Vernacexpr.ProveBody _ ->
203215 CErrors.user_err ~loc Pp.(str"syntax error: missing Definition body")
216+ [%%endif]
204217
205218}
206219
@@ -285,8 +298,8 @@ GLOB_PRINTED BY { fun _ _ _ -> EA.Cmd.pp_glob env sigma }
285298| [ "Structure" inductive_or_record_definition(id) ] -> { EA.Cmd.RecordDecl (of_coq_record_declaration ~atts:[] Vernacexpr.Structure id) }
286299| [ "#[" attributes(atts) "]" "Structure" inductive_or_record_definition(id) ] -> { EA.Cmd.RecordDecl (of_coq_record_declaration ~atts Vernacexpr.Structure id) }
287300
288- | [ "Definition" qualified_name(name) univ_decl_opt(udecl) def_body(def) ] -> { of_coq_definition ~loc ~atts:[] name udecl def }
289- | [ "#[" attributes(atts) "]" "Definition" qualified_name(name) univ_decl_opt(udecl) def_body(def) ] -> { of_coq_definition ~loc ~atts name udecl def }
301+ | [ "Definition" qualified_name(name) univ_decl_opt(udecl) binders(bl) def_body(def) ] -> { of_coq_definition ~loc ~atts:[] name udecl bl def }
302+ | [ "#[" attributes(atts) "]" "Definition" qualified_name(name) univ_decl_opt(udecl) binders(bl) def_body(def) ] -> { of_coq_definition ~loc ~atts name udecl bl def }
290303
291304| [ "Axiom" qualified_name(name) univ_decl_opt(udecl) telescope(typ) colon_constr(t) ] -> {
292305 EA.Cmd.(ConstantDecl { name = snd name; atts = []; udecl; typ = (typ,Some t); red = None; body = None }) }
0 commit comments