diff --git a/src/Idris/Syntax.idr b/src/Idris/Syntax.idr index ee650dcc6..7c712d5e3 100644 --- a/src/Idris/Syntax.idr +++ b/src/Idris/Syntax.idr @@ -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}" diff --git a/tests/idris2/operators/operators011/Test.idr b/tests/idris2/operators/operators011/Test.idr index ec0e3f8d8..fcf137e65 100644 --- a/tests/idris2/operators/operators011/Test.idr +++ b/tests/idris2/operators/operators011/Test.idr @@ -1,2 +1,2 @@ -%hide DoesNotExist.infixl.(+) +%hide DoesNotExist.infixl.(+-+) diff --git a/tests/idris2/operators/operators011/Test4.idr b/tests/idris2/operators/operators011/Test4.idr new file mode 100644 index 000000000..8a26c96fe --- /dev/null +++ b/tests/idris2/operators/operators011/Test4.idr @@ -0,0 +1,4 @@ + +import Module + +%hide DoesNotExist.infixl.(&&++) diff --git a/tests/idris2/operators/operators011/expected b/tests/idris2/operators/operators011/expected index f9c2445fe..e923effa6 100644 --- a/tests/idris2/operators/operators011/expected +++ b/tests/idris2/operators/operators011/expected @@ -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.(&&++) diff --git a/tests/idris2/operators/operators011/run b/tests/idris2/operators/operators011/run index 548300731..151c8ed7a 100755 --- a/tests/idris2/operators/operators011/run +++ b/tests/idris2/operators/operators011/run @@ -4,3 +4,4 @@ check Test.idr check Test1.idr check Test2.idr check Test3.idr +check Test4.idr