Skip to content

Commit 7bfa901

Browse files
committed
Typecheck the result of term unquotation.
In some cases, unquoting could generate terms that were ill-typed, typically when unquoting [I @hole] for some template polymorphic inductive type [I]. Similarly universe levels were not computed at all, which could have led to bizarre failures. To ensure that the unquoted term makes sense at all, we simply perform a call to Typing before returning it. This has a non-trivial cost but since building the term is already linear, this should not hopefully matter that much in practice.
1 parent a08708b commit 7bfa901

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

template-coq/src/g_template_coq.mlg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ TACTIC EXTEND TemplateCoq_denote_term
165165
let env = Proofview.Goal.env gl in
166166
let evm = Proofview.Goal.sigma gl in
167167
let evm, c = Constr_denoter.denote_term env evm (to_constr_evars evm c) in
168+
let evm, _ = Typing.type_of env evm (EConstr.of_constr c) in
168169
Proofview.tclTHEN (Proofview.Unsafe.tclEVARS evm)
169170
(ltac_apply tac (List.map to_ltac_val [EConstr.of_constr c]))
170171
end) }

0 commit comments

Comments
 (0)