@@ -881,15 +881,11 @@ elab ist info emode opts fn tm
881 -- names which have been used elsewhere in the term, since we
881 -- names which have been used elsewhere in the term, since we
882 -- won't be able to use them in the resulting application.
882 -- won't be able to use them in the resulting application.
883 let unique_used = getUniqueUsed (tt_ctxt ist) ptm
883 let unique_used = getUniqueUsed (tt_ctxt ist) ptm
884− let n' = mkN n
884+ let n' = metavarName (namespace info) n
886 defer unique_used n'
886 defer unique_used n'
888 highlightSource nfc (AnnName n' (Just MetavarOutput) Nothing Nothing)
888 highlightSource nfc (AnnName n' (Just MetavarOutput) Nothing Nothing)
889− where mkN n@(NS _ _) = n
890− mkN n = case namespace info of
891− Just xs@(_:_) -> sNS n xs
893 elab' ina fc (PProof ts) = do compute; mapM_ (runTac True ist (elabFC info) fn) ts
889 elab' ina fc (PProof ts) = do compute; mapM_ (runTac True ist (elabFC info) fn) ts
894 elab' ina fc (PTactics ts)
890 elab' ina fc (PTactics ts)
895 | not pattern = do mapM_ (runTac False ist fc fn) ts
891 | not pattern = do mapM_ (runTac False ist fc fn) ts
@@ -1696,6 +1692,11 @@ case_ ind autoSolve ist fn tm = do
1696 else casetac (forget val)
1692 else casetac (forget val)
1697 when autoSolve solveAll
1693 when autoSolve solveAll
1695+-- | Compute the appropriate name for a top-level metavariable
1696+metavarName :: Maybe [String] -> Name -> Name
1697+metavarName _ n@(NS _ _) = n
1698+metavarName (Just (ns@(_:_))) n = sNS n ns
1700runTactical :: IState -> FC -> Env -> Term -> [String] -> ElabD Term
1701runTactical :: IState -> FC -> Env -> Term -> [String] -> ElabD Term
1701runTactical ist fc env tm ns = do tm' <- eval tm
1702runTactical ist fc env tm ns = do tm' <- eval tm
@@ -1974,6 +1975,17 @@ runTactical ist fc env tm ns = do tm' <- eval tm
1974 fmap fst . checkClosed $
1975 fmap fst . checkClosed $
1975 rawPair (Var $ reflm "TT", Var $ reflm "TT")
1976 rawPair (Var $ reflm "TT", Var $ reflm "TT")
1976 (tm', ty')
1977 (tm', ty')
1978+ | n == tacN "prim__Metavar", [n] <- args
1979+ = do n' <- reifyTTName n
1980+ ctxt <- get_context
1982+ -- See documentation above in the elab case for PMetavar
1983+ let unique_used = getUniqueUsed ctxt ptm
1984+ let mvn = metavarName (Just ns) n'
1986+ defer unique_used mvn
1977 | n == tacN "prim__Debug", [ty, msg] <- args
1989 | n == tacN "prim__Debug", [ty, msg] <- args
1978 = do msg' <- eval msg
1990 = do msg' <- eval msg
1979 parts <- reifyReportParts msg
1991 parts <- reifyReportParts msg