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

Macro generates variable with out-of-scope name #344

Open
jespercockx opened this issue Jul 26, 2024 · 0 comments
Open

Macro generates variable with out-of-scope name #344

jespercockx opened this issue Jul 26, 2024 · 0 comments

Comments

@jespercockx
Copy link
Member

I'm using some simple macros to generate parts of my agda2hs code. However, I noticed this can lead to terms being generated that refer to unbound variables. Here is a minimal example:

open import Haskell.Prelude
open import Agda.Builtin.Reflection

macro
  solve : Term  TC ⊤
  solve = unify (var 0 [])

test : Int  Int
test _ = solve

{-# COMPILE AGDA2HS test #-}

This is accepted by agda2hs and produces the following illegal Haskell code:

test :: Int -> Int
test _ = x

We should enforce that a variable with an unusable name such as _ is not used in any part of the generated Haskell code.

@jespercockx jespercockx self-assigned this Jul 26, 2024
jespercockx added a commit to jespercockx/agda-core that referenced this issue Jul 27, 2024
jespercockx added a commit to jespercockx/agda-core that referenced this issue Jul 27, 2024
@jespercockx jespercockx removed their assignment Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant