Skip to content

Commit

Permalink
[ fix agda#5700 ] Give proper scope to metas created by reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
jespercockx committed Dec 15, 2021
1 parent 27b34ec commit 9a85249
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/full/Agda/Syntax/Translation/ReflectedToAbstract.hs
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,16 @@ instance ToAbstract Term where
return $ A.Pi exprNoRange (singleton a) b
R.Sort s -> toAbstract s
R.Lit l -> toAbstract l
R.Meta x es -> toAbstract (A.Underscore info, es)
where info = emptyMetaInfo{ metaNumber = Just x }
R.Unknown -> return $ Underscore emptyMetaInfo
R.Meta x es -> do
info <- mkMetaInfo
let info' = info{ metaNumber = Just x }
toAbstract (A.Underscore info', es)
R.Unknown -> Underscore <$> mkMetaInfo

mkMetaInfo :: ReadTCState m => m MetaInfo
mkMetaInfo = do
scope <- getScope
return $ emptyMetaInfo { metaScope = scope }

mkDef :: HasConstInfo m => QName -> m A.Expr
mkDef f =
Expand Down Expand Up @@ -231,7 +238,7 @@ instance ToAbstract Sort where
PropS x -> mkApp (A.Def propName) <$> toAbstract x
PropLitS x -> return $ A.Def' propName $ A.Suffix x
InfS x -> return $ A.Def' infName $ A.Suffix x
UnknownS -> return $ mkApp (A.Def setName) $ Underscore emptyMetaInfo
UnknownS -> mkApp (A.Def setName) . Underscore <$> mkMetaInfo

instance ToAbstract R.Pattern where
type AbsOfRef R.Pattern = A.Pattern
Expand Down
13 changes: 13 additions & 0 deletions test/interaction/Issue5700.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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

macro
macaroo : Term TC ⊤
macaroo hole = unify hole (con (quote suc) (vArg unknown ∷ []))

test : Nat
test = macaroo
1 change: 1 addition & 0 deletions test/interaction/Issue5700.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
top_command (cmd_load currentFile [])
6 changes: 6 additions & 0 deletions test/interaction/Issue5700.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(agda2-status-action "")
(agda2-info-action "*Type-checking*" "" nil)
(agda2-highlight-clear)
(agda2-status-action "")
(agda2-info-action "*All Goals*" "_n_7 : Nat [ at Issue5700.agda:13,8-15 ] " nil)
((last . 1) . (agda2-goals-action '()))

0 comments on commit 9a85249

Please sign in to comment.