agda / agda

Agda is a dependently typed programming language / interactive theorem prover.

Home Page:https://wiki.portal.chalmers.se/agda/pmwiki.php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sort metas produce ill-typed reflected terms when quoted

UlfNorell opened this issue · comments

open import Agda.Builtin.Reflection renaming (bindTC to _>>=_)
open import Agda.Builtin.Unit
open import Agda.Builtin.Nat
open import Agda.Builtin.List

macro
  `Nat : Term  TC ⊤
  `Nat hole = do
    ty  inferType hole
    _   debugPrint "tactic" 10 (termErr ty ∷ [])
    unify hole (def (quote Nat) [])

boom : `Nat
boom = 1

We hit the impossible on line 462 in Unquote.hs trying to unquote (the Term) meta _13 [] as a sort. Meta 13 is the type of the hole we are trying to fill, and a sort meta.

Culprit is this (introduced in 9d6a654 by @jespercockx)

quoteSort (MetaS x es) = quoteTerm $ MetaV x es

which builds a Term instead of a Sort.

My proposed fix is to return unsupportedSort instead. The alternative is to add a meta constructor to reflected sorts.