@@ -2218,17 +2218,20 @@ matchClause' names i x y = checkRpts $ match (fullApp x) (fullApp y) where
2218substMatches :: [(Name, PTerm)] -> PTerm -> PTerm
2218substMatches :: [(Name, PTerm)] -> PTerm -> PTerm
2219substMatches ms = substMatchesShadow ms []
2219substMatches ms = substMatchesShadow ms []
2221−substMatchesShadow :: [(Name, PTerm)] -> [Name] -> PTerm -> PTerm
2221+-- substMatchesShadow :: [(Name, PTerm)] -> [Name] -> PTerm -> PTerm
2222−substMatchesShadow [] shs t = t
2222+-- substMatchesShadow [] shs t = t
2223−substMatchesShadow ((n,tm):ns) shs t
2223+-- substMatchesShadow ((n,tm):ns) shs t
2224− = substMatchShadow n shs tm (substMatchesShadow ns shs t)
2224+-- = substMatchShadow n shs tm (substMatchesShadow ns shs t)
2226substMatch :: Name -> PTerm -> PTerm -> PTerm
2226substMatch :: Name -> PTerm -> PTerm -> PTerm
2227substMatch n = substMatchShadow n []
2227substMatch n = substMatchShadow n []
2229substMatchShadow :: Name -> [Name] -> PTerm -> PTerm -> PTerm
2229substMatchShadow :: Name -> [Name] -> PTerm -> PTerm -> PTerm
2230−substMatchShadow n shs tm t = sm shs t where
2230+substMatchShadow n shs tm t = substMatchesShadow [(n, tm)] shs t
2232+substMatchesShadow :: [(Name, PTerm)] -> [Name] -> PTerm -> PTerm
2233+substMatchesShadow nmap shs t = sm shs t where
2231− sm xs (PRef _ _ n') | n == n' = tm
2234+ sm xs (PRef _ _ n) | Just tm <- lookup n nmap = tm
2232 sm xs (PLam fc x xfc t sc) = PLam fc x xfc (sm xs t) (sm xs sc)
2235 sm xs (PLam fc x xfc t sc) = PLam fc x xfc (sm xs t) (sm xs sc)
2233 sm xs (PPi p x fc t sc)
2236 sm xs (PPi p x fc t sc)
2234 | x `elem` xs
2237 | x `elem` xs