feat(frontends/lean/elaborator): flag expr quotes containing universe params

This commit is contained in:
Sebastian Ullrich 2017-03-03 18:23:57 +01:00 committed by Leonardo de Moura
parent 5d68938a9c
commit 876a2bee46
3 changed files with 17 additions and 4 deletions

View file

@ -2643,7 +2643,7 @@ expr elaborate_quote(expr e, environment const &env, options const &opts, bool i
}
return none_expr();
});
e = Fun(locals, e);
e = copy_tag(e, Fun(locals, e));
metavar_context ctx;
local_context lctx;
@ -2651,12 +2651,16 @@ expr elaborate_quote(expr e, environment const &env, options const &opts, bool i
e = elab.elaborate(e);
e = elab.finalize(e, true, true).first;
expr body = e;
for (unsigned i = 0; i < aqs.size(); i++)
body = binding_body(body);
if (in_pattern) {
for (unsigned i = 0; i < aqs.size(); i++)
e = binding_body(e);
e = instantiate_rev(e, aqs.size(), aqs.data());
e = instantiate_rev(body, aqs.size(), aqs.data());
e = quote(e);
} else {
if (has_param_univ(body))
throw elaborator_exception(e, "invalid quotation, contains universe parameter");
e = mk_quote_core(e, true);
expr subst = mk_constant(get_expr_subst_name());
for (expr aq : aqs)

View file

@ -0,0 +1,6 @@
meta def f (α a : expr) := ```(@id %%α %%a)
meta def f (α a : expr) := ```(@id (%%α : Type 2) %%a)
set_option pp.universes true
print f

View file

@ -0,0 +1,3 @@
expr_quote.lean:1:32: error: invalid quotation, contains universe parameter
meta def f : expr → expr → expr :=
λ (α a : expr), expr.subst (expr.subst ```(λ (_x_1 : Type 2) (_x_2 : _x_1), id.{3} _x_2) α) a