Skip to content

Commit

Permalink
Typecheck the result of term unquotation.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ppedrot committed Aug 30, 2024
1 parent a08708b commit d809598
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion template-coq/src/denoter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ struct
let evm, ty = aux env evm ty in
evm, Constr.mkArray (UVars.Instance.of_array ([||], [|u|]), arr, def, ty)

in aux env evm trm
in
let evm, trm = aux env evm trm in
let evm, _ = Typing.type_of env evm (EConstr.of_constr trm) in
evm, trm

end

0 comments on commit d809598

Please sign in to comment.