Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using tmMkInductive and tmUnquote unpredictably crashes #1114

Open
MathisBD opened this issue Nov 4, 2024 · 0 comments
Open

Using tmMkInductive and tmUnquote unpredictably crashes #1114

MathisBD opened this issue Nov 4, 2024 · 0 comments

Comments

@MathisBD
Copy link
Collaborator

MathisBD commented Nov 4, 2024

Declaring an inductive (tmMkInductive) and unquoting it (tmUnquote) in the same metacoq command unpredictably fails,
depending on which functions are inlined (see MWE).

Here is a MWE to reproduce the bug (I declare a (trivial) inductive and immediately try to unquote it) :

From MetaCoq.Utils Require Import utils.
From MetaCoq.Template Require Import All.
Import MCMonadNotation.

(* Modify this based on the current file. *)
Definition ind : term := 
  tInd {| inductive_mind := (MPfile ["Bug2"], "Ind") ; inductive_ind := 0 |} [].

(* The simplest inductive you can make. *)
Definition mind_body := {|
  ind_finite := Finite;
  ind_npars := 0;
  ind_params := [];
  ind_bodies := [{|
      ind_name := "Ind";
      ind_indices := [];
      ind_sort := sProp;
      ind_type := tSort sProp;
      ind_kelim := IntoPropSProp;
      ind_ctors :=[];
      ind_projs := [];
      ind_relevance := Relevant
    |}];
  ind_universes := Monomorphic_ctx;
  ind_variance := None
|}.

Definition define_ind : TemplateMonad unit :=
  tmMkInductive' mind_body.

Definition unquote_ind : TemplateMonad unit := 
  tmUnquote ind ;; ret tt.

(* Anomaly : "Inductive Bug2.Ind does not appear in the environment." *)
MetaCoq Run (define_ind ;; unquote_ind).

(* Succeeds. *)
MetaCoq Run define_ind.
MetaCoq Run unquote_ind.

(* Succeeds. *)
MetaCoq Run (tmMkInductive' mind_body ;; unquote_ind).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant