on master help sign in
Fix for repeated variables in instance head

Variables should only be brought into scope once! So remove any repeated variables and only bind them once.

commit636e6e160270ff4288cc18ecdd04d59049d83473 authorEdwin Brady <ecb10@st-andrews.ac.uk> dateFri 23 May 2014, 20:00 (12 years ago) parentb664815
1 file changed+7−7
src/Idris/ElabDecls.hs+7−7
src/Idris/ElabDecls.hs+7−7
@@ -2089,19 +2089,19 @@ elabInstance info syn what fc cs n ps t expn ds = do
20892089
20902090 -- Bring variables in instance head into scope
20912091 ist <- getIState
2092− let headVars = mapMaybe (\p -> case p of
2093− PRef _ n ->
2094− case lookupTy n (tt_ctxt ist) of
2095− [] -> Just n
2096− _ -> Nothing
2097− _ -> Nothing) ps
2092+ let headVars = nub $ mapMaybe (\p -> case p of
2093+ PRef _ n ->
2094+ case lookupTy n (tt_ctxt ist) of
2095+ [] -> Just n
2096+ _ -> Nothing
2097+ _ -> Nothing) ps
20982098-- let lhs = PRef fc iname
20992099 let lhs = PApp fc (PRef fc iname)
21002100 (map (\n -> pimp n (PRef fc n) True) headVars)
21012101 let rhs = PApp fc (PRef fc (instanceName ci))
21022102 (map (pexp . mkMethApp) mtys)
21032103
2104− logLvl 5 $ "Instance LHS " ++ show lhs
2104+ logLvl 5 $ "Instance LHS " ++ show lhs ++ " " ++ show headVars
21052105 logLvl 5 $ "Instance RHS " ++ show rhs
21062106
21072107 let idecls = [PClauses fc [Dictionary] iname