Show unrelated namespace with matching operator name

This commit is contained in:
André Videla 2024-06-17 12:39:37 +01:00
parent f67b303cca
commit 0e09b8d575
5 changed files with 27 additions and 8 deletions

View File

@ -1047,12 +1047,14 @@ removeFixity loc _ key = do
else -- When the fixity is not found, find close matches
let fixityNames : List Name = map fst (toList fixityInfo)
closeNames = !(filterM (coreLift . closeMatch key) fixityNames)
in if null closeNames
sameName : List Name = fst <$> lookupName (dropAllNS key) fixityInfo
similarNamespaces = nub (closeNames ++ sameName)
in if null similarNamespaces
then
throw $ GenericMsg loc "Fixity \{show key} not found"
else
throw $ GenericMsgSol loc "Fixity \{show key} not found" "Did you mean"
(map printFixityHide closeNames)
throw $ GenericMsgSol loc "Fixity \{show key} not found" "Did you mean"
$ map printFixityHide similarNamespaces
where
printFixityHide : Name -> String
printFixityHide nm = "%hide \{show nm}"

View File

@ -1,2 +1,2 @@
%hide DoesNotExist.infixl.(+)
%hide DoesNotExist.infixl.(+-+)

View File

@ -0,0 +1,4 @@
import Module
%hide DoesNotExist.infixl.(&&++)

View File

@ -1,10 +1,10 @@
1/1: Building Test (Test.idr)
Error: Fixity DoesNotExist.infixl.(+) not found
Error: Fixity DoesNotExist.infixl.(+-+) not found
Test:2:1--2:30
Test:2:1--2:32
1 |
2 | %hide DoesNotExist.infixl.(+)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | %hide DoesNotExist.infixl.(+-+)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1/2: Building Module (Module.idr)
2/2: Building Test1 (Test1.idr)
@ -40,3 +40,15 @@ Test3:3:1--3:27
Did you mean:
- %hide Module.infixl.(&&++)
2/2: Building Test4 (Test4.idr)
Error: Fixity DoesNotExist.infixl.(&&++) not found
Test4:4:1--4:33
1 |
2 | import Module
3 |
4 | %hide DoesNotExist.infixl.(&&++)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Did you mean:
- %hide Module.infixl.(&&++)

View File

@ -4,3 +4,4 @@ check Test.idr
check Test1.idr
check Test2.idr
check Test3.idr
check Test4.idr