@@ -211,13 +211,16 @@ pprintErr' i (CantUnify _ x_in y_in e sc s) =
211 _ -> line <> line <> text "Specifically:" <>
211 _ -> line <> line <> text "Specifically:" <>
212 indented (pprintErr' i e) <>
212 indented (pprintErr' i e) <>
213 if (opt_errContext (idris_options i)) then showSc i sc else empty
213 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
215 text "Can't convert" <>
218 text "Can't convert" <>
216− indented (annTm x (pprintTerm' i (map (\ (n, b) -> (n, False)) env)
219+ indented (annTm x_ns (pprintTerm' i (map (\ (n, b) -> (n, False)) env)
217− (delab i (flagUnique x)))) <$>
220+ x)) <$>
218 text "with" <>
221 text "with" <>
219− indented (annTm y (pprintTerm' i (map (\ (n, b) -> (n, False)) env)
222+ indented (annTm y_ns (pprintTerm' i (map (\ (n, b) -> (n, False)) env)
220− (delab i (flagUnique y)))) <>
223+ y)) <>
221 if (opt_errContext (idris_options i)) then line <> showSc i env else empty
224 if (opt_errContext (idris_options i)) then line <> showSc i env else empty
222 where flagUnique (Bind n (Pi t k@(UType u)) sc)
225 where flagUnique (Bind n (Pi t k@(UType u)) sc)
223 = App (P Ref (sUN (show u)) Erased)
226 = App (P Ref (sUN (show u)) Erased)
@@ -331,10 +334,6 @@ pprintErr' i (ReflectionFailed msg err) =
331-- Make sure the machine invented names are shown helpfully to the user, so
334-- Make sure the machine invented names are shown helpfully to the user, so
332-- that any names which differ internally also differ visibly
335-- that any names which differ internally also differ visibly
334−-- FIXME: I can't actually contrive an error to test this! Will revisit later...
336−-- Issue #1590 in the Issue tracker.
337−-- https://github.com/idris-lang/Idris-dev/issues/1590
338renameMNs :: Term -> Term -> (Term, Term, [Name])
337renameMNs :: Term -> Term -> (Term, Term, [Name])
339renameMNs x y = let ns = nub $ allTTNames x ++ allTTNames y
338renameMNs x y = let ns = nub $ allTTNames x ++ allTTNames y
340 newnames = evalState (getRenames [] ns) 1 in
339 newnames = evalState (getRenames [] ns) 1 in
@@ -342,13 +341,23 @@ renameMNs x y = let ns = nub $ allTTNames x ++ allTTNames y
343 getRenames :: [(Name, Name)] -> [Name] -> State Int [(Name, Name)]
342 getRenames :: [(Name, Name)] -> [Name] -> State Int [(Name, Name)]
344 getRenames acc [] = return acc
343 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
347+ let x' = sUN (str x ++ show idx)
348+ getRenames ((n, x') : acc) xs
349+ getRenames acc (n@(UN x) : xs) | rpt x xs
346 = do idx <- get
350 = do idx <- get
347 put (idx + 1)
351 put (idx + 1)
348 let x' = sUN (str x ++ show idx)
352 let x' = sUN (str x ++ show idx)
349 getRenames ((n, x') : acc) xs
353 getRenames ((n, x') : acc) xs
350 getRenames acc (x : xs) = getRenames acc xs
354 getRenames acc (x : xs) = getRenames acc xs
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
352 rename :: [(Name, Name)] -> Term -> Term
361 rename :: [(Name, Name)] -> Term -> Term
353 rename ns (P nt x t) | Just x' <- lookup x ns = P nt x' t
362 rename ns (P nt x t) | Just x' <- lookup x ns = P nt x' t
354 rename ns (App f a) = App (rename ns f) (rename ns a)
363 rename ns (App f a) = App (rename ns f) (rename ns a)