[Git][ghc/ghc][wip/21101] 21101 Error message text for invalid record wildcard match

Sasha Bogicevic (@Bogicevic) gitlab at gitlab.haskell.org
Wed Jul 12 10:51:12 UTC 2023



Sasha Bogicevic pushed to branch wip/21101 at Glasgow Haskell Compiler / GHC


Commits:
33d2dcdb by Sasha Bogicevic at 2023-07-12T12:51:01+02:00
21101 Error message text for invalid record wildcard match

- - - - -


1 changed file:

- compiler/GHC/Tc/Errors/Ppr.hs


Changes:

=====================================
compiler/GHC/Tc/Errors/Ppr.hs
=====================================
@@ -278,9 +278,15 @@ instance Diagnostic TcRnMessage where
       -> mkSimpleDecorated $ text "character literal out of range: '\\" <> char c  <> char '\''
     TcRnIllegalWildcardsInConstructor con
       -> mkSimpleDecorated $
-           vcat [ text "Illegal `{..}' notation for constructor" <+> quotes (ppr con)
-                , nest 2 (text "Record wildcards may not be used for constructors with unlabelled fields.")
-                , nest 2 (text "Possible fix: Remove the `{..}' and add a match for each field of the constructor.")
+           vcat [ text "The data constructor"
+                  <+> quotes (ppr con)
+                  <+> text "does not have named record fields, so a pattern match"
+                  <+> quotes (ppr con)
+                  <+> text " { .. } is incorrect."
+                , text "Possible fixes:"
+                , nest 2 (text "* Replace the pattern '" <+> quotes (ppr con) <+> text "'{ .. }' with" <+> quotes (ppr con))
+                , nest 2 (text "* Replace the pattern '" <+> quotes (ppr con) <+> text "'{ .. }' with" <+> quotes (ppr con) <+> text "{}")
+                , nest 4 (text "This version works even if you add/remove fields to " <+> quotes (ppr con) <+> text "later")
                 ]
     TcRnIgnoringAnnotations anns
       -> mkSimpleDecorated $



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/33d2dcdb6344a12f18e131986bbfad923a941537

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/33d2dcdb6344a12f18e131986bbfad923a941537
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230712/19e83d6e/attachment-0001.html>


More information about the ghc-commits mailing list