Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onlyReduceDefs should not prevent evaluation of macros #5469

Closed
jespercockx opened this issue Jul 7, 2021 · 0 comments · Fixed by #5650
Closed

onlyReduceDefs should not prevent evaluation of macros #5469

jespercockx opened this issue Jul 7, 2021 · 0 comments · Fixed by #5650
Assignees
Labels
reflection Elaborator reflection, macros, tactic arguments type: bug Issues and pull requests about actual bugs
Milestone

Comments

@jespercockx
Copy link
Member

Consider the following example code:

open import Agda.Builtin.List
open import Agda.Builtin.Nat
open import Agda.Builtin.Unit
open import Agda.Builtin.Reflection

pattern vArg x = arg (arg-info visible (modality relevant quantity-ω)) x

make2 : Term  TC ⊤
make2 hole = bindTC (normalise (def (quote _+_) (vArg (lit (nat 1)) ∷ vArg (lit (nat 1)) ∷ []))) (unify hole)

macro
  tester : Term  TC ⊤
  tester hole = onlyReduceDefs (quote _+_ ∷ []) (make2 hole)

_ = tester

The TC action make2 hole unifies the hole with the normalization of 1 + 1, and in the macro tester this is called inside onlyReduceDefs (quote _+_ ∷ []). I would thus expect calling this macro would produce the term 2. However, we get an error instead:

Cannot unquote non-canonical type checking computation
  make2 (meta _14 [])
when checking that the expression unquote tester has type _13

What I think is happening is that the call to onlyReduceDefs prevents the call to make2 from being evaluated. This is unexpected, since onlyReduceDefs should only have an effect on calls to primitive TC operations such as reduce and normalise, not on the evaluation of the macro itself.

@jespercockx jespercockx added type: bug Issues and pull requests about actual bugs reflection Elaborator reflection, macros, tactic arguments labels Jul 7, 2021
@jespercockx jespercockx added this to the 2.6.3 milestone Jul 7, 2021
@jespercockx jespercockx self-assigned this Jul 7, 2021
jespercockx added a commit to jespercockx/agda that referenced this issue Nov 15, 2021
@jespercockx jespercockx linked a pull request Nov 15, 2021 that will close this issue
@andreasabel andreasabel modified the milestones: 2.6.3, 2.6.2.1 Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reflection Elaborator reflection, macros, tactic arguments type: bug Issues and pull requests about actual bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants