Skip to content

Commit d809598

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 d809598

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

template-coq/src/denoter.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ struct
174174
let evm, ty = aux env evm ty in
175175
evm, Constr.mkArray (UVars.Instance.of_array ([||], [|u|]), arr, def, ty)
176176

177-
in aux env evm trm
177+
in
178+
let evm, trm = aux env evm trm in
179+
let evm, _ = Typing.type_of env evm (EConstr.of_constr trm) in
180+
evm, trm
178181

179182
end

0 commit comments

Comments
 (0)