[Git][ghc/ghc][wip/T17879] 2 commits: wip

Jade (@Jade) gitlab at gitlab.haskell.org
Wed Feb 28 18:34:04 UTC 2024



Jade pushed to branch wip/T17879 at Glasgow Haskell Compiler / GHC


Commits:
607f5b87 by Jade at 2024-02-28T12:40:27+01:00
wip

- - - - -
4ef369b2 by Jade at 2024-02-28T19:33:56+01:00
wip

- - - - -


4 changed files:

- compiler/GHC/Parser/Errors/Ppr.hs
- + testsuite/tests/parser/should_fail/T17879.hs
- + testsuite/tests/parser/should_fail/T17879.stderr
- testsuite/tests/parser/should_fail/all.T


Changes:

=====================================
compiler/GHC/Parser/Errors/Ppr.hs
=====================================
@@ -455,13 +455,11 @@ instance Diagnostic PsMessage where
     PsErrIllegalRoleName role _nearby
       -> mkSimpleDecorated $
            text "Illegal role name" <+> quotes (ppr role)
-    PsErrInvalidTypeSignature reason _
+    PsErrInvalidTypeSignature reason lhs
       -> mkSimpleDecorated $ case reason of
-           InvalidTypeSig_DataCon is_op
-             -> if is_op then text "Invalid data constructor operator in type signature" $$
-                              text "an operator must not start with" <+> quotes colon <> dot
-                         else text "Invalid data constructor in type signature" $$
-                              text "a variable or function must not start with an uppercase letter"
+           InvalidTypeSig_DataCon _   -> text "Invalid data constructor" <+> quotes (ppr lhs) <+>
+                                         text "in type signature" <> colon $$
+                                         text "you can only define data constructors in data type declarations."
            InvalidTypeSig_Qualified   -> text "Invalid qualified name in type signature"
            InvalidTypeSig_Application -> text "Invalid application in type signature"
            InvalidTypeSig_Other       -> text "Invalid type signature"


=====================================
testsuite/tests/parser/should_fail/T17879.hs
=====================================
@@ -0,0 +1,4 @@
+module Main where
+
+Foo :: ()
+Foo = ()


=====================================
testsuite/tests/parser/should_fail/T17879.stderr
=====================================
@@ -0,0 +1,5 @@
+
+T17879.hs:3:1: error: [GHC-94426]
+    Invalid data constructor ‘Foo’ in type signature:
+    you can only define data constructors in data type declarations.
+    Suggested fix: Use a lowercase name


=====================================
testsuite/tests/parser/should_fail/all.T
=====================================
@@ -220,3 +220,4 @@ test('T20609b', normal, compile_fail, [''])
 test('T20609c', normal, compile_fail, [''])
 test('T20609d', normal, compile_fail, [''])
 test('SuffixAtFail', normal, compile_fail, ['-fdiagnostics-show-caret'])
+test('T17879', normal, compile_fail, [''])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fc02e8080040b591a77893963c3f21b9aea8b590...4ef369b2ccd48c6c1c713c7bedea684d7ee11542

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fc02e8080040b591a77893963c3f21b9aea8b590...4ef369b2ccd48c6c1c713c7bedea684d7ee11542
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/20240228/e69abc3c/attachment-0001.html>


More information about the ghc-commits mailing list