Print suggestions in a single message
authorWojciech Baranowski <wbaranowski@protonmail.com>
Sat, 13 Apr 2019 09:31:13 +0000 (12:31 +0300)
committerMarge Bot <ben+marge-bot@smart-cactus.org>
Tue, 30 Apr 2019 01:02:38 +0000 (21:02 -0400)
compiler/rename/RnEnv.hs
testsuite/tests/parser/should_fail/readFail001.stderr

index 381ba2b..7f12e05 100644 (file)
@@ -1499,11 +1499,13 @@ lookupBindGroupOcc ctxt what rdr_name
 
     candidates names_in_scope
       = case similar_names of
-          [] -> Outputable.empty
-          _  -> vcat $ map (\x -> text "Perhaps you meant" <+>
-                                  quotes (ppr x) <+>
-                                  parens (pprDefinedAt x))
-                           similar_names
+          []  -> Outputable.empty
+          [n] -> text "Perhaps you meant" <+>
+                 quotes (ppr n) <+>
+                 parens (pprDefinedAt n)
+          _   -> text "Perhaps you meant one of these:" <+>
+                 pprWithCommas (\x -> quotes (ppr x) <+> parens (pprDefinedAt x))
+                               similar_names
       where
         similar_names
           = fuzzyLookup (unpackFS $ occNameFS $ rdrNameOcc rdr_name)
index 0b6d4b4..df2b920 100644 (file)
@@ -1,8 +1,8 @@
 
 readFail001.hs:25:11: error:
     The fixity signature for ‘+#’ lacks an accompanying binding
-      Perhaps you meant ‘+’ (Defined in ‘GHC.Num’)
-      Perhaps you meant ‘++’ (Defined in ‘GHC.Base’)
+      Perhaps you meant one of these: ‘+’ (Defined in ‘GHC.Num’),
+                                      ‘++’ (Defined in ‘GHC.Base’)
 
 readFail001.hs:38:32: error:
     Not in scope: type constructor or class ‘Leaf’