[Git][ghc/ghc][wip/or-pats] Test fixes

David (@knothed) gitlab at gitlab.haskell.org
Mon Feb 13 15:34:23 UTC 2023



David pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC


Commits:
7689564d by David Knothe at 2023-02-13T16:34:18+01:00
Test fixes

- - - - -


6 changed files:

- compiler/GHC/Parser.y
- compiler/GHC/Parser/Lexer.x
- testsuite/tests/parser/should_fail/Or1.hs
- testsuite/tests/parser/should_fail/Or1.stderr
- testsuite/tests/parser/should_fail/Or2.hs
- testsuite/tests/parser/should_fail/Or2.stderr


Changes:

=====================================
compiler/GHC/Parser.y
=====================================
@@ -3825,7 +3825,6 @@ varid :: { LocatedN RdrName }
         | 'forall'         { sL1n $1 $! mkUnqual varName (fsLit "forall") }
         | 'family'         { sL1n $1 $! mkUnqual varName (fsLit "family") }
         | 'role'           { sL1n $1 $! mkUnqual varName (fsLit "role") }
-        | 'one'            { sL1n $1 $! mkUnqual varName (fsLit "one") }
         -- If this changes relative to tyvarid, update 'checkRuleTyVarBndrNames'
         -- in GHC.Parser.PostProcess
         -- See Note [Parsing explicit foralls in Rules]
@@ -3852,7 +3851,7 @@ varsym_no_minus :: { LocatedN RdrName } -- varsym not including '-'
 
 -- These special_ids are treated as keywords in various places,
 -- but as ordinary ids elsewhere.   'special_id' collects all these
--- except 'unsafe', 'interruptible', 'forall', 'family', 'role', 'stock', 'one'
+-- except 'unsafe', 'interruptible', 'forall', 'family', 'role', 'stock'
 -- and 'anyclass', whose treatment differs depending on context
 special_id :: { Located FastString }
 special_id
@@ -3866,6 +3865,7 @@ special_id
         | 'ccall'               { sL1 $1 (fsLit "ccall") }
         | 'capi'                { sL1 $1 (fsLit "capi") }
         | 'prim'                { sL1 $1 (fsLit "prim") }
+        | 'one'                 { sL1 $1 (fsLit "one") }
         | 'javascript'          { sL1 $1 (fsLit "javascript") }
         -- See Note [%shift: special_id -> 'group']
         | 'group' %shift        { sL1 $1 (fsLit "group") }


=====================================
compiler/GHC/Parser/Lexer.x
=====================================
@@ -999,7 +999,7 @@ reservedWordsFM = listToUFM $
          ( "mdo",            ITmdo Nothing,   xbit RecursiveDoBit),
              -- See Note [Lexing type pseudo-keywords]
          ( "family",         ITfamily,        0 ),
-         ( "one",            ITone,           xbit OrPatternsBit),
+         ( "one",            ITone,           0),
          ( "role",           ITrole,          0 ),
          ( "pattern",        ITpattern,       xbit PatternSynonymsBit),
          ( "static",         ITstatic,        xbit StaticPointersBit ),


=====================================
testsuite/tests/parser/should_fail/Or1.hs
=====================================
@@ -1,9 +1,6 @@
 module Main where
 
-main = g 3 && h 1
+main = print $ h 1
 
-h y = case y of
-  (one of 2, 3) -> True
-
-g x = case x of
-  one of 4, 5 -> False
\ No newline at end of file
+h one = case one of
+  (one of 2, 3) -> True
\ No newline at end of file


=====================================
testsuite/tests/parser/should_fail/Or1.stderr
=====================================
@@ -2,5 +2,3 @@
 Or1.hs:6:4: error: [GHC-29847]
     Illegal or-pattern: one of 2, 3
     Suggested fix: Perhaps you intended to use OrPatterns
-
-Or1.hs:9:7: error: [GHC-58481] parse error on input ‘of’


=====================================
testsuite/tests/parser/should_fail/Or2.hs
=====================================
@@ -1,6 +1,9 @@
-{-# LANGUAGE OrPatterns #-}
+{-# LANGUAGE OrPatterns, PatternSynonyms #-}
 
 module Main where
 
 main = case 3 of
-  (one of 4) -> False
\ No newline at end of file
+  (one of 4) -> False
+
+g x = case x of
+  one of 4, 5 -> False


=====================================
testsuite/tests/parser/should_fail/Or2.stderr
=====================================
@@ -1,3 +1,5 @@
 
 Or2.hs:6:4: error: [GHC-96152]
     An or-pattern needs at least two alternatives: one of 4
+
+Or2.hs:9:7: error: [GHC-58481] parse error on input ‘of’



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7689564d58a89c35520139834bdb7056c1ddba7c

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7689564d58a89c35520139834bdb7056c1ddba7c
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/20230213/23c3ef5a/attachment-0001.html>


More information about the ghc-commits mailing list