@@ -1691,7 +1691,7 @@ addImpl = addImpl' False [] []
16911691
16921692addImpl' :: Bool -> [Name] -> [Name] -> [Name] -> IState -> PTerm -> PTerm
16931693addImpl' inpat env infns imp_meths ist ptm
1694− = mkUniqueNames env [] (ai inpat False (zip env (repeat Nothing)) [] ptm)
1694+ = ai inpat False (zip env (repeat Nothing)) [] (mkUniqueNames env [] ptm)
16951695 where
16961696 topname = case ptm of
16971697 PRef _ _ n -> n
@@ -2272,7 +2272,8 @@ shadow n n' t = sm 0 t where
22722272 sm 0 (PTyped x y) = PTyped (sm 0 x) (sm 0 y)
22732273 sm 0 (PPair f hls p x y) = PPair f hls p (sm 0 x) (sm 0 y)
22742274 sm 0 (PDPair f hls p x t y) = PDPair f hls p (sm 0 x) (sm 0 t) (sm 0 y)
2275− sm 0 (PAlternative ms a as) = PAlternative ms a (map (sm 0) as)
2275+ sm 0 (PAlternative ms a as)
2276+ = PAlternative (map shadowAlt ms) a (map (sm 0) as)
22762277 sm 0 (PTactics ts) = PTactics (map (fmap (sm 0)) ts)
22772278 sm 0 (PProof ts) = PProof (map (fmap (sm 0)) ts)
22782279 sm 0 (PHidden x) = PHidden (sm 0 x)
@@ -2283,6 +2284,10 @@ shadow n n' t = sm 0 t where
22832284 sm ql (PUnquote tm) = PUnquote (sm (ql - 1) tm)
22842285 sm ql x = descend (sm ql) x
22852286
2287+ shadowAlt p@(x, oldn) = (update x, update oldn)
2288+ update oldn | n == oldn = n'
2289+ | otherwise = oldn
2290+
22862291-- | Rename any binders which are repeated (so that we don't have to mess
22872292-- about with shadowing anywhere else).
22882293mkUniqueNames :: [Name] -> [(Name, Name)] -> PTerm -> PTerm
@@ -2384,7 +2389,7 @@ mkUniqueNames env shadows tm
23842389 mkUniq 0 nmap (PAlternative ns b as)
23852390 -- store the nmap and defer the rest until we've pruned the set
23862391 -- during elaboration
2387− = return $ PAlternative (M.toList nmap ++ ns) b as
2392+ = return $ PAlternative (ns ++ M.toList nmap) b as
23882393 mkUniq 0 nmap (PHidden t) = liftM PHidden (mkUniq 0 nmap t)
23892394 mkUniq 0 nmap (PUnifyLog t) = liftM PUnifyLog (mkUniq 0 nmap t)
23902395 mkUniq 0 nmap (PDisamb n t) = liftM (PDisamb n) (mkUniq 0 nmap t)