@@ -211,13 +211,16 @@ pprintErr' i (CantUnify _ x_in y_in e sc s) =
211211 _ -> line <> line <> text "Specifically:" <>
212212 indented (pprintErr' i e) <>
213213 if (opt_errContext (idris_options i)) then showSc i sc else empty
214−pprintErr' i (CantConvert x y env) =
214+pprintErr' i (CantConvert x_in y_in env) =
215+ let (x_ns, y_ns, nms) = renameMNs x_in y_in
216+ (x, y) = addImplicitDiffs (delab i (flagUnique x_ns))
217+ (delab i (flagUnique y_ns)) in
215218 text "Can't convert" <>
216− indented (annTm x (pprintTerm' i (map (\ (n, b) -> (n, False)) env)
217− (delab i (flagUnique x)))) <$>
219+ indented (annTm x_ns (pprintTerm' i (map (\ (n, b) -> (n, False)) env)
220+ x)) <$>
218221 text "with" <>
219− indented (annTm y (pprintTerm' i (map (\ (n, b) -> (n, False)) env)
220− (delab i (flagUnique y)))) <>
222+ indented (annTm y_ns (pprintTerm' i (map (\ (n, b) -> (n, False)) env)
223+ y)) <>
221224 if (opt_errContext (idris_options i)) then line <> showSc i env else empty
222225 where flagUnique (Bind n (Pi t k@(UType u)) sc)
223226 = App (P Ref (sUN (show u)) Erased)
@@ -331,10 +334,6 @@ pprintErr' i (ReflectionFailed msg err) =
331334-- Make sure the machine invented names are shown helpfully to the user, so
332335-- that any names which differ internally also differ visibly
333336
334−-- FIXME: I can't actually contrive an error to test this! Will revisit later...
335−--
336−-- Issue #1590 in the Issue tracker.
337−-- https://github.com/idris-lang/Idris-dev/issues/1590
338337renameMNs :: Term -> Term -> (Term, Term, [Name])
339338renameMNs x y = let ns = nub $ allTTNames x ++ allTTNames y
340339 newnames = evalState (getRenames [] ns) 1 in
@@ -342,13 +341,23 @@ renameMNs x y = let ns = nub $ allTTNames x ++ allTTNames y
342341 where
343342 getRenames :: [(Name, Name)] -> [Name] -> State Int [(Name, Name)]
344343 getRenames acc [] = return acc
345− getRenames acc (n@(MN i x) : xs) | UN x `elem` xs
344+ getRenames acc (n@(MN i x) : xs) | rpt x xs
345+ = do idx <- get
346+ put (idx + 1)
347+ let x' = sUN (str x ++ show idx)
348+ getRenames ((n, x') : acc) xs
349+ getRenames acc (n@(UN x) : xs) | rpt x xs
346350 = do idx <- get
347351 put (idx + 1)
348352 let x' = sUN (str x ++ show idx)
349353 getRenames ((n, x') : acc) xs
350354 getRenames acc (x : xs) = getRenames acc xs
351355
356+ rpt x [] = False
357+ rpt x (UN y : xs) | x == y = True
358+ rpt x (MN i y : xs) | x == y = True
359+ rpt x (_ : xs) = rpt x xs
360+
352361 rename :: [(Name, Name)] -> Term -> Term
353362 rename ns (P nt x t) | Just x' <- lookup x ns = P nt x' t
354363 rename ns (App f a) = App (rename ns f) (rename ns a)