diff options
author | Kavon Farvardin <kavon@farvard.in> | 2018-09-23 15:29:37 -0500 |
---|---|---|
committer | Kavon Farvardin <kavon@farvard.in> | 2018-09-23 15:29:37 -0500 |
commit | 84c2ad99582391005b5e873198b15e9e9eb4f78d (patch) | |
tree | caa8c2f2ec7e97fbb4977263c6817c9af5025cf4 /testsuite/tests/parser | |
parent | 8ddb47cfcf5776e9a3c55fd37947c8a95e00fa12 (diff) | |
parent | e68b439fe5de61b9a2ca51af472185c62ccb8b46 (diff) | |
download | haskell-wip/T13904.tar.gz |
update to current master againwip/T13904
Diffstat (limited to 'testsuite/tests/parser')
79 files changed, 1962 insertions, 713 deletions
diff --git a/testsuite/tests/parser/should_compile/BlockArguments.hs b/testsuite/tests/parser/should_compile/BlockArguments.hs new file mode 100644 index 0000000000..f74c09d97c --- /dev/null +++ b/testsuite/tests/parser/should_compile/BlockArguments.hs @@ -0,0 +1,25 @@ +{-# LANGUAGE BlockArguments #-} + +module BlockArguments where + +import Control.Monad + +foo :: IO () +foo = when True do + return () + +foo' :: IO () +foo' = do + forM [1 .. 10] \x -> + print x + + forM [1 .. 10] \x -> do + print x + print x + + return () + +foo'' :: IO () +foo'' = when + do True + do return () diff --git a/testsuite/tests/parser/should_compile/BlockArgumentsLambdaCase.hs b/testsuite/tests/parser/should_compile/BlockArgumentsLambdaCase.hs new file mode 100644 index 0000000000..8e336c28f4 --- /dev/null +++ b/testsuite/tests/parser/should_compile/BlockArgumentsLambdaCase.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE BlockArguments, LambdaCase #-} + +module BlockArgumentsLambdaCase where + +import Control.Monad + +foo' :: IO () +foo' = do + forM [Just 3, Nothing] \case + Just 3 -> print 3 + _ -> print 5 + + return () diff --git a/testsuite/tests/parser/should_compile/DumpParsedAst.stderr b/testsuite/tests/parser/should_compile/DumpParsedAst.stderr index ad3680e578..231017322f 100644 --- a/testsuite/tests/parser/should_compile/DumpParsedAst.stderr +++ b/testsuite/tests/parser/should_compile/DumpParsedAst.stderr @@ -2,236 +2,240 @@ ==================== Parser AST ==================== ({ DumpParsedAst.hs:1:1 } - (HsModule - (Just - ({ DumpParsedAst.hs:3:8-20 }{ModuleName: DumpParsedAst})) - (Nothing) - [] - [ - ({ DumpParsedAst.hs:5:1-30 } - (TyClD - (DataDecl + (HsModule + (Just + ({ DumpParsedAst.hs:3:8-20 } + {ModuleName: DumpParsedAst})) + (Nothing) + [] + [({ DumpParsedAst.hs:5:1-30 } + (TyClD + (NoExt) + (DataDecl + (NoExt) ({ DumpParsedAst.hs:5:6-10 } - (Unqual {OccName: Peano})) - (HsQTvs - (PlaceHolder) - [] - (PlaceHolder)) - (Prefix) - (HsDataDefn - (DataType) + (Unqual + {OccName: Peano})) + (HsQTvs + (NoExt) + []) + (Prefix) + (HsDataDefn + (NoExt) + (DataType) ({ <no location info> } - []) - (Nothing) - (Nothing) - [ - ({ DumpParsedAst.hs:5:14-17 } - (ConDeclH98 + []) + (Nothing) + (Nothing) + [({ DumpParsedAst.hs:5:14-17 } + (ConDeclH98 + (NoExt) ({ DumpParsedAst.hs:5:14-17 } - (Unqual {OccName: Zero})) - (Nothing) - (Just - ({ <no location info> } - [])) - (PrefixCon - []) - (Nothing))), - ({ DumpParsedAst.hs:5:21-30 } - (ConDeclH98 + (Unqual + {OccName: Zero})) + ({ <no location info> } + (False)) + [] + (Nothing) + (PrefixCon + []) + (Nothing))) + ,({ DumpParsedAst.hs:5:21-30 } + (ConDeclH98 + (NoExt) ({ DumpParsedAst.hs:5:21-24 } - (Unqual {OccName: Succ})) - (Nothing) - (Just - ({ <no location info> } - [])) - (PrefixCon - [ - ({ DumpParsedAst.hs:5:26-30 } - (HsTyVar - (NotPromoted) + (Unqual + {OccName: Succ})) + ({ <no location info> } + (False)) + [] + (Nothing) + (PrefixCon + [({ DumpParsedAst.hs:5:26-30 } + (HsTyVar + (NoExt) + (NotPromoted) ({ DumpParsedAst.hs:5:26-30 } - (Unqual {OccName: Peano}))))]) - (Nothing)))] + (Unqual + {OccName: Peano}))))]) + (Nothing)))] ({ <no location info> } - [])) - (PlaceHolder) - (PlaceHolder)))), - ({ DumpParsedAst.hs:7:1-39 } - (TyClD - (FamDecl - (FamilyDecl - (ClosedTypeFamily - (Just - [ - ({ DumpParsedAst.hs:8:3-36 } - (TyFamEqn - ({ DumpParsedAst.hs:8:3-8 } - (Unqual {OccName: Length})) - (HsIB - (PlaceHolder) - [ - ({ DumpParsedAst.hs:8:10-17 } - (HsParTy + []))))) + ,({ DumpParsedAst.hs:7:1-39 } + (TyClD + (NoExt) + (FamDecl + (NoExt) + (FamilyDecl + (NoExt) + (ClosedTypeFamily + (Just + [({ DumpParsedAst.hs:8:3-36 } + (HsIB + (NoExt) + (FamEqn + (NoExt) + ({ DumpParsedAst.hs:8:3-8 } + (Unqual + {OccName: Length})) + [({ DumpParsedAst.hs:8:10-17 } + (HsParTy + (NoExt) ({ DumpParsedAst.hs:8:11-16 } - (HsAppsTy - [ - ({ DumpParsedAst.hs:8:11 } - (HsAppPrefix - ({ DumpParsedAst.hs:8:11 } - (HsTyVar - (NotPromoted) - ({ DumpParsedAst.hs:8:11 } - (Unqual {OccName: a})))))), - ({ DumpParsedAst.hs:8:13 } - (HsAppInfix - ({ DumpParsedAst.hs:8:13 } - (Exact {Name: ghc-prim:GHC.Types.:{(w) d}})))), - ({ DumpParsedAst.hs:8:15-16 } - (HsAppPrefix - ({ DumpParsedAst.hs:8:15-16 } - (HsTyVar - (NotPromoted) - ({ DumpParsedAst.hs:8:15-16 } - (Unqual {OccName: as}))))))]))))] - (PlaceHolder)) - (Prefix) - ({ DumpParsedAst.hs:8:21-36 } - (HsAppsTy - [ + (HsOpTy + (NoExt) + ({ DumpParsedAst.hs:8:11 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpParsedAst.hs:8:11 } + (Unqual + {OccName: a})))) + ({ DumpParsedAst.hs:8:13 } + (Exact + {Name: :})) + ({ DumpParsedAst.hs:8:15-16 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpParsedAst.hs:8:15-16 } + (Unqual + {OccName: as}))))))))] + (Prefix) + ({ DumpParsedAst.hs:8:21-36 } + (HsAppTy + (NoExt) ({ DumpParsedAst.hs:8:21-24 } - (HsAppPrefix + (HsTyVar + (NoExt) + (NotPromoted) ({ DumpParsedAst.hs:8:21-24 } - (HsTyVar - (NotPromoted) - ({ DumpParsedAst.hs:8:21-24 } - (Unqual {OccName: Succ})))))), + (Unqual + {OccName: Succ})))) ({ DumpParsedAst.hs:8:26-36 } - (HsAppPrefix - ({ DumpParsedAst.hs:8:26-36 } - (HsParTy - ({ DumpParsedAst.hs:8:27-35 } - (HsAppsTy - [ - ({ DumpParsedAst.hs:8:27-32 } - (HsAppPrefix - ({ DumpParsedAst.hs:8:27-32 } - (HsTyVar - (NotPromoted) - ({ DumpParsedAst.hs:8:27-32 } - (Unqual {OccName: Length})))))), - ({ DumpParsedAst.hs:8:34-35 } - (HsAppPrefix - ({ DumpParsedAst.hs:8:34-35 } - (HsTyVar - (NotPromoted) - ({ DumpParsedAst.hs:8:34-35 } - (Unqual {OccName: as}))))))]))))))])))), - ({ DumpParsedAst.hs:9:3-24 } - (TyFamEqn - ({ DumpParsedAst.hs:9:3-8 } - (Unqual {OccName: Length})) - (HsIB - (PlaceHolder) - [ - ({ DumpParsedAst.hs:9:10-12 } - (HsExplicitListTy - (Promoted) - (PlaceHolder) - []))] - (PlaceHolder)) - (Prefix) - ({ DumpParsedAst.hs:9:21-24 } - (HsAppsTy - [ + (HsParTy + (NoExt) + ({ DumpParsedAst.hs:8:27-35 } + (HsAppTy + (NoExt) + ({ DumpParsedAst.hs:8:27-32 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpParsedAst.hs:8:27-32 } + (Unqual + {OccName: Length})))) + ({ DumpParsedAst.hs:8:34-35 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpParsedAst.hs:8:34-35 } + (Unqual + {OccName: as}))))))))))))) + ,({ DumpParsedAst.hs:9:3-24 } + (HsIB + (NoExt) + (FamEqn + (NoExt) + ({ DumpParsedAst.hs:9:3-8 } + (Unqual + {OccName: Length})) + [({ DumpParsedAst.hs:9:10-12 } + (HsExplicitListTy + (NoExt) + (Promoted) + []))] + (Prefix) + ({ DumpParsedAst.hs:9:21-24 } + (HsTyVar + (NoExt) + (NotPromoted) ({ DumpParsedAst.hs:9:21-24 } - (HsAppPrefix - ({ DumpParsedAst.hs:9:21-24 } - (HsTyVar - (NotPromoted) - ({ DumpParsedAst.hs:9:21-24 } - (Unqual {OccName: Zero}))))))]))))])) + (Unqual + {OccName: Zero})))))))])) ({ DumpParsedAst.hs:7:13-18 } - (Unqual {OccName: Length})) - (HsQTvs - (PlaceHolder) - [ - ({ DumpParsedAst.hs:7:20-30 } - (KindedTyVar + (Unqual + {OccName: Length})) + (HsQTvs + (NoExt) + [({ DumpParsedAst.hs:7:20-30 } + (KindedTyVar + (NoExt) ({ DumpParsedAst.hs:7:21-22 } - (Unqual {OccName: as})) + (Unqual + {OccName: as})) ({ DumpParsedAst.hs:7:27-29 } - (HsAppsTy - [ - ({ DumpParsedAst.hs:7:27-29 } - (HsAppPrefix - ({ DumpParsedAst.hs:7:27-29 } - (HsListTy - ({ DumpParsedAst.hs:7:28 } - (HsAppsTy - [ - ({ DumpParsedAst.hs:7:28 } - (HsAppPrefix - ({ DumpParsedAst.hs:7:28 } - (HsTyVar - (NotPromoted) - ({ DumpParsedAst.hs:7:28 } - (Unqual {OccName: k}))))))]))))))]))))] - (PlaceHolder)) - (Prefix) + (HsListTy + (NoExt) + ({ DumpParsedAst.hs:7:28 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpParsedAst.hs:7:28 } + (Unqual + {OccName: k}))))))))]) + (Prefix) ({ DumpParsedAst.hs:7:32-39 } - (KindSig + (KindSig + (NoExt) ({ DumpParsedAst.hs:7:35-39 } - (HsAppsTy - [ - ({ DumpParsedAst.hs:7:35-39 } - (HsAppPrefix - ({ DumpParsedAst.hs:7:35-39 } - (HsTyVar - (NotPromoted) - ({ DumpParsedAst.hs:7:35-39 } - (Unqual {OccName: Peano}))))))])))) - (Nothing))))), - ({ DumpParsedAst.hs:11:1-23 } - (ValD - (FunBind + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpParsedAst.hs:7:35-39 } + (Unqual + {OccName: Peano})))))) + (Nothing))))) + ,({ DumpParsedAst.hs:11:1-23 } + (ValD + (NoExt) + (FunBind + (NoExt) ({ DumpParsedAst.hs:11:1-4 } - (Unqual {OccName: main})) - (MG + (Unqual + {OccName: main})) + (MG + (NoExt) ({ DumpParsedAst.hs:11:1-23 } - [ - ({ DumpParsedAst.hs:11:1-23 } - (Match - (FunRhs + [({ DumpParsedAst.hs:11:1-23 } + (Match + (NoExt) + (FunRhs ({ DumpParsedAst.hs:11:1-4 } - (Unqual {OccName: main})) - (Prefix) - (NoSrcStrict)) - [] - (Nothing) - (GRHSs - [ - ({ DumpParsedAst.hs:11:6-23 } - (GRHS - [] + (Unqual + {OccName: main})) + (Prefix) + (NoSrcStrict)) + [] + (GRHSs + (NoExt) + [({ DumpParsedAst.hs:11:6-23 } + (GRHS + (NoExt) + [] ({ DumpParsedAst.hs:11:8-23 } - (HsApp + (HsApp + (NoExt) ({ DumpParsedAst.hs:11:8-15 } - (HsVar + (HsVar + (NoExt) ({ DumpParsedAst.hs:11:8-15 } - (Unqual {OccName: putStrLn})))) + (Unqual + {OccName: putStrLn})))) ({ DumpParsedAst.hs:11:17-23 } - (HsLit - (HsString - (SourceText "\"hello\"") {FastString: "hello"})))))))] + (HsLit + (NoExt) + (HsString + (SourceText + "\"hello\"") + {FastString: "hello"})))))))] ({ <no location info> } - (EmptyLocalBinds)))))]) - [] - (PlaceHolder) - (FromSource)) - (WpHole) - (PlaceHolder) - [])))] - (Nothing) + (EmptyLocalBinds + (NoExt))))))]) + (FromSource)) + (WpHole) + [])))] + (Nothing) (Nothing))) diff --git a/testsuite/tests/parser/should_compile/DumpRenamedAst.hs b/testsuite/tests/parser/should_compile/DumpRenamedAst.hs index cb23ad5085..bf3e372461 100644 --- a/testsuite/tests/parser/should_compile/DumpRenamedAst.hs +++ b/testsuite/tests/parser/should_compile/DumpRenamedAst.hs @@ -1,4 +1,5 @@ -{-# LANGUAGE DataKinds, PolyKinds, TypeOperators, TypeFamilies #-} +{-# LANGUAGE DataKinds, GADTs, PolyKinds, RankNTypes, TypeOperators, + TypeFamilies, StarIsType #-} module DumpRenamedAst where @@ -8,4 +9,10 @@ type family Length (as :: [k]) :: Peano where Length (a : as) = Succ (Length as) Length '[] = Zero +data family Nat :: k -> k -> * +-- Ensure that the `k` in the type pattern and `k` in the kind signature have +-- the same binding site. +newtype instance Nat (a :: k -> *) :: (k -> *) -> * where + Nat :: (forall xx. f xx -> g xx) -> Nat f g + main = putStrLn "hello" diff --git a/testsuite/tests/parser/should_compile/DumpRenamedAst.stderr b/testsuite/tests/parser/should_compile/DumpRenamedAst.stderr index c873ee148b..2c1a0ec7df 100644 --- a/testsuite/tests/parser/should_compile/DumpRenamedAst.stderr +++ b/testsuite/tests/parser/should_compile/DumpRenamedAst.stderr @@ -1,193 +1,454 @@ ==================== Renamer ==================== -(HsGroup - (ValBindsOut - [ - ((,) - (NonRecursive) {Bag(Located (HsBind Name)): - [ - ({ DumpRenamedAst.hs:11:1-23 } - (FunBind - ({ DumpRenamedAst.hs:11:1-4 }{Name: main:DumpRenamedAst.main{v}}) - (MG - ({ DumpRenamedAst.hs:11:1-23 } - [ - ({ DumpRenamedAst.hs:11:1-23 } - (Match - (FunRhs - ({ DumpRenamedAst.hs:11:1-4 }{Name: main:DumpRenamedAst.main{v}}) - (Prefix) - (NoSrcStrict)) - [] - (Nothing) - (GRHSs - [ - ({ DumpRenamedAst.hs:11:6-23 } - (GRHS - [] - ({ DumpRenamedAst.hs:11:8-23 } - (HsApp - ({ DumpRenamedAst.hs:11:8-15 } - (HsVar - ({ DumpRenamedAst.hs:11:8-15 }{Name: base:System.IO.putStrLn{v}}))) - ({ DumpRenamedAst.hs:11:17-23 } - (HsLit - (HsString - (SourceText "\"hello\"") {FastString: "hello"})))))))] - ({ <no location info> } - (EmptyLocalBinds)))))]) - [] - (PlaceHolder) - (FromSource)) - (WpHole) {NameSet: - []} - []))]})] - []) - [] - [ - (TyClGroup - [ - ({ DumpRenamedAst.hs:5:1-30 } - (DataDecl - ({ DumpRenamedAst.hs:5:6-10 }{Name: main:DumpRenamedAst.Peano{tc}}) - (HsQTvs - [] - [] {NameSet: - []}) - (Prefix) - (HsDataDefn - (DataType) - ({ <no location info> } - []) - (Nothing) - (Nothing) - [ - ({ DumpRenamedAst.hs:5:14-17 } - (ConDeclH98 - ({ DumpRenamedAst.hs:5:14-17 }{Name: main:DumpRenamedAst.Zero{d}}) - (Nothing) - (Just - ({ <no location info> } - [])) - (PrefixCon - []) - (Nothing))), - ({ DumpRenamedAst.hs:5:21-30 } - (ConDeclH98 - ({ DumpRenamedAst.hs:5:21-24 }{Name: main:DumpRenamedAst.Succ{d}}) - (Nothing) - (Just - ({ <no location info> } - [])) - (PrefixCon - [ - ({ DumpRenamedAst.hs:5:26-30 } - (HsTyVar - (NotPromoted) - ({ DumpRenamedAst.hs:5:26-30 }{Name: main:DumpRenamedAst.Peano{tc}})))]) - (Nothing)))] - ({ <no location info> } - [])) - (True) {NameSet: - [{Name: main:DumpRenamedAst.Peano{tc}}]}))] - [] - []), - (TyClGroup - [ - ({ DumpRenamedAst.hs:7:1-39 } - (FamDecl - (FamilyDecl - (ClosedTypeFamily - (Just - [ - ({ DumpRenamedAst.hs:8:3-36 } - (TyFamEqn - ({ DumpRenamedAst.hs:8:3-8 }{Name: main:DumpRenamedAst.Length{tc}}) - (HsIB - [{Name: a{tv}},{Name: as{tv}}] - [ - ({ DumpRenamedAst.hs:8:10-17 } - (HsParTy - ({ DumpRenamedAst.hs:8:11-16 } - (HsOpTy - ({ DumpRenamedAst.hs:8:11 } - (HsTyVar - (NotPromoted) - ({ DumpRenamedAst.hs:8:11 }{Name: a{tv}}))) - ({ DumpRenamedAst.hs:8:13 }{Name: ghc-prim:GHC.Types.:{(w) d}}) - ({ DumpRenamedAst.hs:8:15-16 } - (HsTyVar - (NotPromoted) - ({ DumpRenamedAst.hs:8:15-16 }{Name: as{tv}})))))))] - (True)) - (Prefix) - ({ DumpRenamedAst.hs:8:21-36 } - (HsAppTy - ({ DumpRenamedAst.hs:8:21-24 } - (HsTyVar - (NotPromoted) - ({ DumpRenamedAst.hs:8:21-24 }{Name: main:DumpRenamedAst.Succ{d}}))) - ({ DumpRenamedAst.hs:8:26-36 } - (HsParTy - ({ DumpRenamedAst.hs:8:27-35 } - (HsAppTy - ({ DumpRenamedAst.hs:8:27-32 } - (HsTyVar - (NotPromoted) - ({ DumpRenamedAst.hs:8:27-32 }{Name: main:DumpRenamedAst.Length{tc}}))) - ({ DumpRenamedAst.hs:8:34-35 } - (HsTyVar - (NotPromoted) - ({ DumpRenamedAst.hs:8:34-35 }{Name: as{tv}}))))))))))), - ({ DumpRenamedAst.hs:9:3-24 } - (TyFamEqn - ({ DumpRenamedAst.hs:9:3-8 }{Name: main:DumpRenamedAst.Length{tc}}) - (HsIB - [] - [ - ({ DumpRenamedAst.hs:9:10-12 } - (HsExplicitListTy - (Promoted) - (PlaceHolder) - []))] - (True)) - (Prefix) - ({ DumpRenamedAst.hs:9:21-24 } - (HsTyVar - (NotPromoted) - ({ DumpRenamedAst.hs:9:21-24 }{Name: main:DumpRenamedAst.Zero{d}})))))])) - ({ DumpRenamedAst.hs:7:13-18 }{Name: main:DumpRenamedAst.Length{tc}}) - (HsQTvs - [{Name: k{tv}}] - [ - ({ DumpRenamedAst.hs:7:20-30 } - (KindedTyVar - ({ DumpRenamedAst.hs:7:21-22 }{Name: as{tv}}) - ({ DumpRenamedAst.hs:7:27-29 } - (HsListTy - ({ DumpRenamedAst.hs:7:28 } - (HsTyVar - (NotPromoted) - ({ DumpRenamedAst.hs:7:28 }{Name: k{tv}})))))))] {NameSet: - []}) - (Prefix) - ({ DumpRenamedAst.hs:7:32-39 } - (KindSig - ({ DumpRenamedAst.hs:7:35-39 } - (HsTyVar - (NotPromoted) - ({ DumpRenamedAst.hs:7:35-39 }{Name: main:DumpRenamedAst.Peano{tc}}))))) - (Nothing))))] - [] - [])] - [] - [] - [] - [] - [] - [] - [] - [] - []) +(Just + ((,,,) + (HsGroup + (NoExt) + (XValBindsLR + (NValBinds + [((,) + (NonRecursive) + {Bag(Located (HsBind Name)): + [({ DumpRenamedAst.hs:18:1-23 } + (FunBind + {NameSet: + []} + ({ DumpRenamedAst.hs:18:1-4 } + {Name: DumpRenamedAst.main}) + (MG + (NoExt) + ({ DumpRenamedAst.hs:18:1-23 } + [({ DumpRenamedAst.hs:18:1-23 } + (Match + (NoExt) + (FunRhs + ({ DumpRenamedAst.hs:18:1-4 } + {Name: DumpRenamedAst.main}) + (Prefix) + (NoSrcStrict)) + [] + (GRHSs + (NoExt) + [({ DumpRenamedAst.hs:18:6-23 } + (GRHS + (NoExt) + [] + ({ DumpRenamedAst.hs:18:8-23 } + (HsApp + (NoExt) + ({ DumpRenamedAst.hs:18:8-15 } + (HsVar + (NoExt) + ({ DumpRenamedAst.hs:18:8-15 } + {Name: System.IO.putStrLn}))) + ({ DumpRenamedAst.hs:18:17-23 } + (HsLit + (NoExt) + (HsString + (SourceText + "\"hello\"") + {FastString: "hello"})))))))] + ({ <no location info> } + (EmptyLocalBinds + (NoExt))))))]) + (FromSource)) + (WpHole) + []))]})] + [])) + [] + [(TyClGroup + (NoExt) + [({ DumpRenamedAst.hs:6:1-30 } + (DataDecl + (DataDeclRn + (True) + {NameSet: + [{Name: DumpRenamedAst.Peano}]}) + ({ DumpRenamedAst.hs:6:6-10 } + {Name: DumpRenamedAst.Peano}) + (HsQTvs + (HsQTvsRn + [] + {NameSet: + []}) + []) + (Prefix) + (HsDataDefn + (NoExt) + (DataType) + ({ <no location info> } + []) + (Nothing) + (Nothing) + [({ DumpRenamedAst.hs:6:14-17 } + (ConDeclH98 + (NoExt) + ({ DumpRenamedAst.hs:6:14-17 } + {Name: DumpRenamedAst.Zero}) + ({ <no location info> } + (False)) + [] + (Nothing) + (PrefixCon + []) + (Nothing))) + ,({ DumpRenamedAst.hs:6:21-30 } + (ConDeclH98 + (NoExt) + ({ DumpRenamedAst.hs:6:21-24 } + {Name: DumpRenamedAst.Succ}) + ({ <no location info> } + (False)) + [] + (Nothing) + (PrefixCon + [({ DumpRenamedAst.hs:6:26-30 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:6:26-30 } + {Name: DumpRenamedAst.Peano})))]) + (Nothing)))] + ({ <no location info> } + []))))] + [] + []) + ,(TyClGroup + (NoExt) + [({ DumpRenamedAst.hs:8:1-39 } + (FamDecl + (NoExt) + (FamilyDecl + (NoExt) + (ClosedTypeFamily + (Just + [({ DumpRenamedAst.hs:9:3-36 } + (HsIB + [{Name: a} + ,{Name: as}] + (FamEqn + (NoExt) + ({ DumpRenamedAst.hs:9:3-8 } + {Name: DumpRenamedAst.Length}) + [({ DumpRenamedAst.hs:9:10-17 } + (HsParTy + (NoExt) + ({ DumpRenamedAst.hs:9:11-16 } + (HsOpTy + (NoExt) + ({ DumpRenamedAst.hs:9:11 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:9:11 } + {Name: a}))) + ({ DumpRenamedAst.hs:9:13 } + {Name: :}) + ({ DumpRenamedAst.hs:9:15-16 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:9:15-16 } + {Name: as})))))))] + (Prefix) + ({ DumpRenamedAst.hs:9:21-36 } + (HsAppTy + (NoExt) + ({ DumpRenamedAst.hs:9:21-24 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:9:21-24 } + {Name: DumpRenamedAst.Succ}))) + ({ DumpRenamedAst.hs:9:26-36 } + (HsParTy + (NoExt) + ({ DumpRenamedAst.hs:9:27-35 } + (HsAppTy + (NoExt) + ({ DumpRenamedAst.hs:9:27-32 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:9:27-32 } + {Name: DumpRenamedAst.Length}))) + ({ DumpRenamedAst.hs:9:34-35 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:9:34-35 } + {Name: as})))))))))))) + ,({ DumpRenamedAst.hs:10:3-24 } + (HsIB + [] + (FamEqn + (NoExt) + ({ DumpRenamedAst.hs:10:3-8 } + {Name: DumpRenamedAst.Length}) + [({ DumpRenamedAst.hs:10:10-12 } + (HsExplicitListTy + (NoExt) + (Promoted) + []))] + (Prefix) + ({ DumpRenamedAst.hs:10:21-24 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:10:21-24 } + {Name: DumpRenamedAst.Zero}))))))])) + ({ DumpRenamedAst.hs:8:13-18 } + {Name: DumpRenamedAst.Length}) + (HsQTvs + (HsQTvsRn + [{Name: k}] + {NameSet: + []}) + [({ DumpRenamedAst.hs:8:20-30 } + (KindedTyVar + (NoExt) + ({ DumpRenamedAst.hs:8:21-22 } + {Name: as}) + ({ DumpRenamedAst.hs:8:27-29 } + (HsListTy + (NoExt) + ({ DumpRenamedAst.hs:8:28 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:8:28 } + {Name: k})))))))]) + (Prefix) + ({ DumpRenamedAst.hs:8:32-39 } + (KindSig + (NoExt) + ({ DumpRenamedAst.hs:8:35-39 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:8:35-39 } + {Name: DumpRenamedAst.Peano}))))) + (Nothing))))] + [] + []) + ,(TyClGroup + (NoExt) + [({ DumpRenamedAst.hs:12:1-30 } + (FamDecl + (NoExt) + (FamilyDecl + (NoExt) + (DataFamily) + ({ DumpRenamedAst.hs:12:13-15 } + {Name: DumpRenamedAst.Nat}) + (HsQTvs + (HsQTvsRn + [{Name: k}] + {NameSet: + []}) + []) + (Prefix) + ({ DumpRenamedAst.hs:12:17-30 } + (KindSig + (NoExt) + ({ DumpRenamedAst.hs:12:20-30 } + (HsFunTy + (NoExt) + ({ DumpRenamedAst.hs:12:20 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:12:20 } + {Name: k}))) + ({ DumpRenamedAst.hs:12:25-30 } + (HsFunTy + (NoExt) + ({ DumpRenamedAst.hs:12:25 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:12:25 } + {Name: k}))) + ({ DumpRenamedAst.hs:12:30 } + (HsStarTy + (NoExt) + (False))))))))) + (Nothing))))] + [] + [({ DumpRenamedAst.hs:(15,1)-(16,45) } + (DataFamInstD + (NoExt) + (DataFamInstDecl + (HsIB + [{Name: k} + ,{Name: a}] + (FamEqn + (NoExt) + ({ DumpRenamedAst.hs:15:18-20 } + {Name: DumpRenamedAst.Nat}) + [({ DumpRenamedAst.hs:15:22-34 } + (HsKindSig + (NoExt) + ({ DumpRenamedAst.hs:15:23 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:15:23 } + {Name: a}))) + ({ DumpRenamedAst.hs:15:28-33 } + (HsFunTy + (NoExt) + ({ DumpRenamedAst.hs:15:28 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:15:28 } + {Name: k}))) + ({ DumpRenamedAst.hs:15:33 } + (HsStarTy + (NoExt) + (False)))))))] + (Prefix) + (HsDataDefn + (NoExt) + (NewType) + ({ <no location info> } + []) + (Nothing) + (Just + ({ DumpRenamedAst.hs:15:39-51 } + (HsFunTy + (NoExt) + ({ DumpRenamedAst.hs:15:39-46 } + (HsParTy + (NoExt) + ({ DumpRenamedAst.hs:15:40-45 } + (HsFunTy + (NoExt) + ({ DumpRenamedAst.hs:15:40 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:15:40 } + {Name: k}))) + ({ DumpRenamedAst.hs:15:45 } + (HsStarTy + (NoExt) + (False))))))) + ({ DumpRenamedAst.hs:15:51 } + (HsStarTy + (NoExt) + (False)))))) + [({ DumpRenamedAst.hs:16:3-45 } + (ConDeclGADT + (NoExt) + [({ DumpRenamedAst.hs:16:3-5 } + {Name: DumpRenamedAst.Nat})] + ({ DumpRenamedAst.hs:16:10-45 } + (False)) + (HsQTvs + (HsQTvsRn + [{Name: f} + ,{Name: g}] + {NameSet: + []}) + []) + (Nothing) + (PrefixCon + [({ DumpRenamedAst.hs:16:10-34 } + (HsParTy + (NoExt) + ({ DumpRenamedAst.hs:16:11-33 } + (HsForAllTy + (NoExt) + [({ DumpRenamedAst.hs:16:18-19 } + (UserTyVar + (NoExt) + ({ DumpRenamedAst.hs:16:18-19 } + {Name: xx})))] + ({ DumpRenamedAst.hs:16:22-33 } + (HsFunTy + (NoExt) + ({ DumpRenamedAst.hs:16:22-25 } + (HsAppTy + (NoExt) + ({ DumpRenamedAst.hs:16:22 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:16:22 } + {Name: f}))) + ({ DumpRenamedAst.hs:16:24-25 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:16:24-25 } + {Name: xx}))))) + ({ DumpRenamedAst.hs:16:30-33 } + (HsAppTy + (NoExt) + ({ DumpRenamedAst.hs:16:30 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:16:30 } + {Name: g}))) + ({ DumpRenamedAst.hs:16:32-33 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:16:32-33 } + {Name: xx})))))))))))]) + ({ DumpRenamedAst.hs:16:39-45 } + (HsAppTy + (NoExt) + ({ DumpRenamedAst.hs:16:39-43 } + (HsAppTy + (NoExt) + ({ DumpRenamedAst.hs:16:39-41 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:16:39-41 } + {Name: DumpRenamedAst.Nat}))) + ({ DumpRenamedAst.hs:16:43 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:16:43 } + {Name: f}))))) + ({ DumpRenamedAst.hs:16:45 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpRenamedAst.hs:16:45 } + {Name: g}))))) + (Nothing)))] + ({ <no location info> } + [])))))))])] + [] + [] + [] + [] + [] + [] + [] + []) + [({ DumpRenamedAst.hs:4:8-21 } + (ImportDecl + (NoExt) + (NoSourceText) + ({ DumpRenamedAst.hs:4:8-21 } + {ModuleName: Prelude}) + (Nothing) + (False) + (False) + (False) + (True) + (Nothing) + (Nothing)))] + (Nothing) + (Nothing))) + diff --git a/testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr b/testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr index 663a7d7f2e..8e3e868fb9 100644 --- a/testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr +++ b/testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr @@ -1,279 +1,371 @@ ==================== Typechecker ==================== -{Bag(Located (HsBind Var)): -[ - ({ <no location info> } - (VarBind {Var: (main:DumpTypecheckedAst.$tcPeano{v} [lidx] :: ghc-prim:GHC.Types.TyCon{tc})} - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsConLikeOut - ({abstract:ConLike}))) - ({ <no location info> } - (HsLit - {HsWord{64}Prim - (14073232900889011755) - (NoSourceText)})))) - ({ <no location info> } - (HsLit - {HsWord{64}Prim - (2739668351064589274) - (NoSourceText)})))) - ({ <no location info> } - (HsVar - ({ <no location info> }{Var: (main:DumpTypecheckedAst.$trModule{v} [lidx] :: ghc-prim:GHC.Types.Module{tc})}))))) - ({ <no location info> } - (HsPar - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsConLikeOut - ({abstract:ConLike}))) - ({ <no location info> } - (HsLit - (HsStringPrim - (NoSourceText) "Peano"))))))))) - ({ <no location info> } - (HsLit - {HsInt{64}Prim - (0) - (SourceText "0")})))) - ({ <no location info> } - (HsVar - ({ <no location info> }{Var: (ghc-prim:GHC.Types.krep$*{v} [gid] :: ghc-prim:GHC.Types.KindRep{tc})}))))) - (False))), - ({ <no location info> } - (VarBind {Var: (main:DumpTypecheckedAst.$tc'Zero{v} [lidx] :: ghc-prim:GHC.Types.TyCon{tc})} - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsConLikeOut - ({abstract:ConLike}))) - ({ <no location info> } - (HsLit - {HsWord{64}Prim - (13760111476013868540) - (NoSourceText)})))) - ({ <no location info> } - (HsLit - {HsWord{64}Prim - (12314848029315386153) - (NoSourceText)})))) - ({ <no location info> } - (HsVar - ({ <no location info> }{Var: (main:DumpTypecheckedAst.$trModule{v} [lidx] :: ghc-prim:GHC.Types.Module{tc})}))))) - ({ <no location info> } - (HsPar - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsConLikeOut - ({abstract:ConLike}))) - ({ <no location info> } - (HsLit - (HsStringPrim - (NoSourceText) "'Zero"))))))))) - ({ <no location info> } - (HsLit - {HsInt{64}Prim - (0) - (SourceText "0")})))) - ({ <no location info> } - (HsVar - ({ <no location info> }{Var: ($krep{v} [lid] :: ghc-prim:GHC.Types.KindRep{tc})}))))) - (False))), - ({ <no location info> } - (VarBind {Var: (main:DumpTypecheckedAst.$tc'Succ{v} [lidx] :: ghc-prim:GHC.Types.TyCon{tc})} - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsConLikeOut - ({abstract:ConLike}))) - ({ <no location info> } - (HsLit - {HsWord{64}Prim - (1143980031331647856) - (NoSourceText)})))) - ({ <no location info> } - (HsLit - {HsWord{64}Prim - (14802086722010293686) - (NoSourceText)})))) - ({ <no location info> } - (HsVar - ({ <no location info> }{Var: (main:DumpTypecheckedAst.$trModule{v} [lidx] :: ghc-prim:GHC.Types.Module{tc})}))))) - ({ <no location info> } - (HsPar - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsConLikeOut - ({abstract:ConLike}))) - ({ <no location info> } - (HsLit - (HsStringPrim - (NoSourceText) "'Succ"))))))))) - ({ <no location info> } - (HsLit - {HsInt{64}Prim - (0) - (SourceText "0")})))) - ({ <no location info> } - (HsVar - ({ <no location info> }{Var: ($krep{v} [lid] :: ghc-prim:GHC.Types.KindRep{tc})}))))) - (False))), - ({ <no location info> } - (VarBind {Var: ($krep{v} [lid] :: ghc-prim:GHC.Types.KindRep{tc})} - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsConLikeOut - ({abstract:ConLike}))) - ({ <no location info> } - (HsVar - ({ <no location info> }{Var: ($krep{v} [lid] :: ghc-prim:GHC.Types.KindRep{tc})}))))) - ({ <no location info> } - (HsVar - ({ <no location info> }{Var: ($krep{v} [lid] :: ghc-prim:GHC.Types.KindRep{tc})}))))) - (False))), - ({ <no location info> } - (VarBind {Var: ($krep{v} [lid] :: ghc-prim:GHC.Types.KindRep{tc})} - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsConLikeOut - ({abstract:ConLike}))) - ({ <no location info> } - (HsVar - ({ <no location info> }{Var: (main:DumpTypecheckedAst.$tcPeano{v} [lidx] :: ghc-prim:GHC.Types.TyCon{tc})}))))) - ({ <no location info> } - (HsWrap - (WpTyApp - (TyConApp - ({abstract:TyCon}) - [])) - (HsConLikeOut - ({abstract:ConLike})))))) - (False))), - ({ <no location info> } - (VarBind {Var: (main:DumpTypecheckedAst.$trModule{v} [lidx] :: ghc-prim:GHC.Types.Module{tc})} - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsConLikeOut - ({abstract:ConLike}))) - ({ <no location info> } - (HsPar - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsConLikeOut - ({abstract:ConLike}))) - ({ <no location info> } - (HsLit - (HsStringPrim - (NoSourceText) "main"))))))))) - ({ <no location info> } - (HsPar - ({ <no location info> } - (HsApp - ({ <no location info> } - (HsConLikeOut - ({abstract:ConLike}))) - ({ <no location info> } - (HsLit - (HsStringPrim - (NoSourceText) "DumpTypecheckedAst"))))))))) - (False))), - ({ DumpTypecheckedAst.hs:11:1-23 } - (AbsBinds - [] - [] - [ - (ABE {Var: (main:DumpTypecheckedAst.main{v} [lid] :: ghc-prim:GHC.Types.IO{tc} - ())} {Var: (main{v} [lid] :: ghc-prim:GHC.Types.IO{tc} ())} - (WpHole) - (SpecPrags - []))] - [ - ({abstract:TcEvBinds})] {Bag(Located (HsBind Var)): - [ - ({ DumpTypecheckedAst.hs:11:1-23 } - (FunBind - ({ DumpTypecheckedAst.hs:11:1-4 }{Var: (main{v} [lid] :: ghc-prim:GHC.Types.IO{tc} ())}) - (MG - ({ DumpTypecheckedAst.hs:11:1-23 } - [ - ({ DumpTypecheckedAst.hs:11:1-23 } - (Match - (FunRhs - ({ DumpTypecheckedAst.hs:11:1-4 }{Name: main:DumpTypecheckedAst.main{v}}) - (Prefix) - (NoSrcStrict)) - [] - (Nothing) - (GRHSs - [ - ({ DumpTypecheckedAst.hs:11:6-23 } - (GRHS - [] - ({ DumpTypecheckedAst.hs:11:8-23 } - (HsApp - ({ DumpTypecheckedAst.hs:11:8-15 } - (HsVar - ({ <no location info> }{Var: (base:System.IO.putStrLn{v} [gid] :: base:GHC.Base.String{tc} - -> ghc-prim:GHC.Types.IO{tc} ())}))) - ({ DumpTypecheckedAst.hs:11:17-23 } - (HsLit - (HsString - (SourceText "\"hello\"") {FastString: "hello"})))))))] + +{Bag(Located (HsBind Var)): + [({ <no location info> } + (VarBind + (NoExt) + {Var: DumpTypecheckedAst.$tcPeano} + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsConLikeOut + (NoExt) + ({abstract:ConLike}))) + ({ <no location info> } + (HsLit + (NoExt) + {HsWord{64}Prim (14073232900889011755) (NoSourceText)})))) + ({ <no location info> } + (HsLit + (NoExt) + {HsWord{64}Prim (2739668351064589274) (NoSourceText)})))) + ({ <no location info> } + (HsVar + (NoExt) + ({ <no location info> } + {Var: DumpTypecheckedAst.$trModule}))))) + ({ <no location info> } + (HsPar + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsConLikeOut + (NoExt) + ({abstract:ConLike}))) + ({ <no location info> } + (HsLit + (NoExt) + (HsStringPrim + (NoSourceText) + "Peano"))))))))) + ({ <no location info> } + (HsLit + (NoExt) + {HsInt{64}Prim (0) (SourceText + "0")})))) + ({ <no location info> } + (HsVar + (NoExt) + ({ <no location info> } + {Var: GHC.Types.krep$*}))))) + (False))) + ,({ <no location info> } + (VarBind + (NoExt) + {Var: DumpTypecheckedAst.$tc'Zero} + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsConLikeOut + (NoExt) + ({abstract:ConLike}))) + ({ <no location info> } + (HsLit + (NoExt) + {HsWord{64}Prim (13760111476013868540) (NoSourceText)})))) + ({ <no location info> } + (HsLit + (NoExt) + {HsWord{64}Prim (12314848029315386153) (NoSourceText)})))) + ({ <no location info> } + (HsVar + (NoExt) + ({ <no location info> } + {Var: DumpTypecheckedAst.$trModule}))))) + ({ <no location info> } + (HsPar + (NoExt) ({ <no location info> } - (EmptyLocalBinds)))))]) - [] - (TyConApp - ({abstract:TyCon}) - [ - (TyConApp - ({abstract:TyCon}) - [])]) - (FromSource)) - (WpHole) {NameSet: - []} - []))]}))]} + (HsApp + (NoExt) + ({ <no location info> } + (HsConLikeOut + (NoExt) + ({abstract:ConLike}))) + ({ <no location info> } + (HsLit + (NoExt) + (HsStringPrim + (NoSourceText) + "'Zero"))))))))) + ({ <no location info> } + (HsLit + (NoExt) + {HsInt{64}Prim (0) (SourceText + "0")})))) + ({ <no location info> } + (HsVar + (NoExt) + ({ <no location info> } + {Var: $krep}))))) + (False))) + ,({ <no location info> } + (VarBind + (NoExt) + {Var: DumpTypecheckedAst.$tc'Succ} + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsConLikeOut + (NoExt) + ({abstract:ConLike}))) + ({ <no location info> } + (HsLit + (NoExt) + {HsWord{64}Prim (1143980031331647856) (NoSourceText)})))) + ({ <no location info> } + (HsLit + (NoExt) + {HsWord{64}Prim (14802086722010293686) (NoSourceText)})))) + ({ <no location info> } + (HsVar + (NoExt) + ({ <no location info> } + {Var: DumpTypecheckedAst.$trModule}))))) + ({ <no location info> } + (HsPar + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsConLikeOut + (NoExt) + ({abstract:ConLike}))) + ({ <no location info> } + (HsLit + (NoExt) + (HsStringPrim + (NoSourceText) + "'Succ"))))))))) + ({ <no location info> } + (HsLit + (NoExt) + {HsInt{64}Prim (0) (SourceText + "0")})))) + ({ <no location info> } + (HsVar + (NoExt) + ({ <no location info> } + {Var: $krep}))))) + (False))) + ,({ <no location info> } + (VarBind + (NoExt) + {Var: $krep} + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsConLikeOut + (NoExt) + ({abstract:ConLike}))) + ({ <no location info> } + (HsVar + (NoExt) + ({ <no location info> } + {Var: $krep}))))) + ({ <no location info> } + (HsVar + (NoExt) + ({ <no location info> } + {Var: $krep}))))) + (False))) + ,({ <no location info> } + (VarBind + (NoExt) + {Var: $krep} + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsConLikeOut + (NoExt) + ({abstract:ConLike}))) + ({ <no location info> } + (HsVar + (NoExt) + ({ <no location info> } + {Var: DumpTypecheckedAst.$tcPeano}))))) + ({ <no location info> } + (HsWrap + (NoExt) + (WpTyApp + (TyConApp + ({abstract:TyCon}) + [])) + (HsConLikeOut + (NoExt) + ({abstract:ConLike})))))) + (False))) + ,({ <no location info> } + (VarBind + (NoExt) + {Var: DumpTypecheckedAst.$trModule} + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsConLikeOut + (NoExt) + ({abstract:ConLike}))) + ({ <no location info> } + (HsPar + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsConLikeOut + (NoExt) + ({abstract:ConLike}))) + ({ <no location info> } + (HsLit + (NoExt) + (HsStringPrim + (NoSourceText) + "main"))))))))) + ({ <no location info> } + (HsPar + (NoExt) + ({ <no location info> } + (HsApp + (NoExt) + ({ <no location info> } + (HsConLikeOut + (NoExt) + ({abstract:ConLike}))) + ({ <no location info> } + (HsLit + (NoExt) + (HsStringPrim + (NoSourceText) + "DumpTypecheckedAst"))))))))) + (False))) + ,({ DumpTypecheckedAst.hs:11:1-23 } + (AbsBinds + (NoExt) + [] + [] + [(ABE + (NoExt) + {Var: main} + {Var: main} + (WpHole) + (SpecPrags + []))] + [({abstract:TcEvBinds})] + {Bag(Located (HsBind Var)): + [({ DumpTypecheckedAst.hs:11:1-23 } + (FunBind + {NameSet: + []} + ({ DumpTypecheckedAst.hs:11:1-4 } + {Var: main}) + (MG + (MatchGroupTc + [] + (TyConApp + ({abstract:TyCon}) + [(TyConApp + ({abstract:TyCon}) + [])])) + ({ DumpTypecheckedAst.hs:11:1-23 } + [({ DumpTypecheckedAst.hs:11:1-23 } + (Match + (NoExt) + (FunRhs + ({ DumpTypecheckedAst.hs:11:1-4 } + {Name: main}) + (Prefix) + (NoSrcStrict)) + [] + (GRHSs + (NoExt) + [({ DumpTypecheckedAst.hs:11:6-23 } + (GRHS + (NoExt) + [] + ({ DumpTypecheckedAst.hs:11:8-23 } + (HsApp + (NoExt) + ({ DumpTypecheckedAst.hs:11:8-15 } + (HsVar + (NoExt) + ({ <no location info> } + {Var: putStrLn}))) + ({ DumpTypecheckedAst.hs:11:17-23 } + (HsLit + (NoExt) + (HsString + (SourceText + "\"hello\"") + {FastString: "hello"})))))))] + ({ <no location info> } + (EmptyLocalBinds + (NoExt))))))]) + (FromSource)) + (WpHole) + []))]} + (False)))]} diff --git a/testsuite/tests/parser/should_compile/NoBlockArguments.hs b/testsuite/tests/parser/should_compile/NoBlockArguments.hs new file mode 100644 index 0000000000..169a460203 --- /dev/null +++ b/testsuite/tests/parser/should_compile/NoBlockArguments.hs @@ -0,0 +1,8 @@ +module NoBlockArguments where + +-- Make sure things parse normally +f :: a -> a +f = id + +foo :: [Int] +foo = f [x | x <- [1 .. 10]] diff --git a/testsuite/tests/parser/should_compile/T10379.hs b/testsuite/tests/parser/should_compile/T10379.hs index 1eb5f96382..eb231c4415 100644 --- a/testsuite/tests/parser/should_compile/T10379.hs +++ b/testsuite/tests/parser/should_compile/T10379.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE KindSignatures, GADTs, DataKinds, TypeOperators #-} +{-# LANGUAGE KindSignatures, GADTs, DataKinds #-} module Foo where data Foo1 :: [*] -> * where diff --git a/testsuite/tests/parser/should_compile/T10855.hs b/testsuite/tests/parser/should_compile/T10855.hs new file mode 100644 index 0000000000..cc66f5d4b3 --- /dev/null +++ b/testsuite/tests/parser/should_compile/T10855.hs @@ -0,0 +1,5 @@ +module T10855 where + +bool :: Int +bool = - case 3 > 5 of False -> 0; True -> (-1) +main = print (- do 4) diff --git a/testsuite/tests/parser/should_compile/T13986.hs b/testsuite/tests/parser/should_compile/T13986.hs new file mode 100644 index 0000000000..b1b4882a35 --- /dev/null +++ b/testsuite/tests/parser/should_compile/T13986.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE TypeApplications #-} + +module T13986 where + +foo x₁@True = 10 diff --git a/testsuite/tests/parser/should_compile/T14189.hs b/testsuite/tests/parser/should_compile/T14189.hs new file mode 100644 index 0000000000..c26ebd7dee --- /dev/null +++ b/testsuite/tests/parser/should_compile/T14189.hs @@ -0,0 +1,6 @@ +module T14189 + ( + MyType (f,NT) + ) where + +data MyType = MT Int | NT | F { f :: Int } diff --git a/testsuite/tests/parser/should_compile/T14189.stderr b/testsuite/tests/parser/should_compile/T14189.stderr new file mode 100644 index 0000000000..e5aff5bf88 --- /dev/null +++ b/testsuite/tests/parser/should_compile/T14189.stderr @@ -0,0 +1,148 @@ + +==================== Renamer ==================== + +(Just + ((,,,) + (HsGroup + (NoExt) + (XValBindsLR + (NValBinds + [] + [])) + [] + [(TyClGroup + (NoExt) + [({ T14189.hs:6:1-42 } + (DataDecl + (DataDeclRn + (True) + {NameSet: + [{Name: GHC.Types.Int}]}) + ({ T14189.hs:6:6-11 } + {Name: T14189.MyType}) + (HsQTvs + (HsQTvsRn + [] + {NameSet: + []}) + []) + (Prefix) + (HsDataDefn + (NoExt) + (DataType) + ({ <no location info> } + []) + (Nothing) + (Nothing) + [({ T14189.hs:6:15-20 } + (ConDeclH98 + (NoExt) + ({ T14189.hs:6:15-16 } + {Name: T14189.MT}) + ({ <no location info> } + (False)) + [] + (Nothing) + (PrefixCon + [({ T14189.hs:6:18-20 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ T14189.hs:6:18-20 } + {Name: GHC.Types.Int})))]) + (Nothing))) + ,({ T14189.hs:6:24-25 } + (ConDeclH98 + (NoExt) + ({ T14189.hs:6:24-25 } + {Name: T14189.NT}) + ({ <no location info> } + (False)) + [] + (Nothing) + (PrefixCon + []) + (Nothing))) + ,({ T14189.hs:6:29-42 } + (ConDeclH98 + (NoExt) + ({ T14189.hs:6:29 } + {Name: T14189.F}) + ({ <no location info> } + (False)) + [] + (Nothing) + (RecCon + ({ T14189.hs:6:31-42 } + [({ T14189.hs:6:33-40 } + (ConDeclField + (NoExt) + [({ T14189.hs:6:33 } + (FieldOcc + {Name: T14189.f} + ({ T14189.hs:6:33 } + (Unqual + {OccName: f}))))] + ({ T14189.hs:6:38-40 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ T14189.hs:6:38-40 } + {Name: GHC.Types.Int}))) + (Nothing)))])) + (Nothing)))] + ({ <no location info> } + []))))] + [] + [])] + [] + [] + [] + [] + [] + [] + [] + []) + [({ T14189.hs:1:8-13 } + (ImportDecl + (NoExt) + (NoSourceText) + ({ T14189.hs:1:8-13 } + {ModuleName: Prelude}) + (Nothing) + (False) + (False) + (False) + (True) + (Nothing) + (Nothing)))] + (Just + [((,) + ({ T14189.hs:3:3-15 } + (IEThingWith + (NoExt) + ({ T14189.hs:3:3-8 } + (IEName + ({ T14189.hs:3:3-8 } + {Name: T14189.MyType}))) + (NoIEWildcard) + [({ T14189.hs:3:13-14 } + (IEName + ({ T14189.hs:3:13-14 } + {Name: T14189.NT})))] + [({ T14189.hs:3:11 } + (FieldLabel + {FastString: "f"} + (False) + {Name: T14189.f}))])) + [(AvailTC + {Name: T14189.MyType} + [{Name: T14189.MyType} + ,{Name: T14189.NT}] + [(FieldLabel + {FastString: "f"} + (False) + {Name: T14189.f})])])]) + (Nothing))) + + diff --git a/testsuite/tests/parser/should_compile/T15139.hs b/testsuite/tests/parser/should_compile/T15139.hs new file mode 100644 index 0000000000..9f98bb1319 --- /dev/null +++ b/testsuite/tests/parser/should_compile/T15139.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE EmptyCase #-} +{-# LANGUAGE TypeOperators #-} +module T15139 where + +import Data.Type.Equality + +can'tHappen :: Int :~: Bool +can'tHappen = undefined + +f1, f2, g :: Bool -> Bool +f1 True = case can'tHappen of {} +f2 True = case can'tHappen of +g True = case () of () -> True diff --git a/testsuite/tests/parser/should_compile/T15139.stderr b/testsuite/tests/parser/should_compile/T15139.stderr new file mode 100644 index 0000000000..010bd7440c --- /dev/null +++ b/testsuite/tests/parser/should_compile/T15139.stderr @@ -0,0 +1,21 @@ + +T15139.hs:11:1: warning: [-Wincomplete-patterns (in -Wextra)] + Pattern match(es) are non-exhaustive + In an equation for ‘f1’: Patterns not matched: False + | +11 | f1 True = case can'tHappen of {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +T15139.hs:12:1: warning: [-Wincomplete-patterns (in -Wextra)] + Pattern match(es) are non-exhaustive + In an equation for ‘f2’: Patterns not matched: False + | +12 | f2 True = case can'tHappen of + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +T15139.hs:13:1: warning: [-Wincomplete-patterns (in -Wextra)] + Pattern match(es) are non-exhaustive + In an equation for ‘g’: Patterns not matched: False + | +13 | g True = case () of () -> True + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/testsuite/tests/parser/should_compile/T15279.hs b/testsuite/tests/parser/should_compile/T15279.hs new file mode 100644 index 0000000000..b80bd32b54 --- /dev/null +++ b/testsuite/tests/parser/should_compile/T15279.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE CPP #-} +{-# OPTIONS_GHC -ddump-parsed-ast #-} +module T15279 where + +foo :: Char -> Char +#include "T15279.hs-incl" +foo _ = 'a' diff --git a/testsuite/tests/parser/should_compile/T15279.hs-incl b/testsuite/tests/parser/should_compile/T15279.hs-incl new file mode 100644 index 0000000000..d6385f28e3 --- /dev/null +++ b/testsuite/tests/parser/should_compile/T15279.hs-incl @@ -0,0 +1,2 @@ +foo 'a' = 'b' +foo 'b' = 'c' diff --git a/testsuite/tests/parser/should_compile/T15279.stderr b/testsuite/tests/parser/should_compile/T15279.stderr new file mode 100644 index 0000000000..ff215a763d --- /dev/null +++ b/testsuite/tests/parser/should_compile/T15279.stderr @@ -0,0 +1,3 @@ +(MG +(NoExt) +({ <combineSrcSpans: files differ> } diff --git a/testsuite/tests/parser/should_compile/T15323.hs b/testsuite/tests/parser/should_compile/T15323.hs new file mode 100644 index 0000000000..ffc8ad85f0 --- /dev/null +++ b/testsuite/tests/parser/should_compile/T15323.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE GADTs #-} +{-# LANGUAGE RankNTypes #-} +module T15323 where + +data MaybeDefault v where + TestParens :: (forall v . (Eq v) => MaybeDefault v) diff --git a/testsuite/tests/parser/should_compile/T15323.stderr b/testsuite/tests/parser/should_compile/T15323.stderr new file mode 100644 index 0000000000..93b254bf32 --- /dev/null +++ b/testsuite/tests/parser/should_compile/T15323.stderr @@ -0,0 +1,96 @@ + +==================== Parser AST ==================== + +({ T15323.hs:1:1 } + (HsModule + (Just + ({ T15323.hs:3:8-13 } + {ModuleName: T15323})) + (Nothing) + [] + [({ T15323.hs:(5,1)-(6,56) } + (TyClD + (NoExt) + (DataDecl + (NoExt) + ({ T15323.hs:5:6-17 } + (Unqual + {OccName: MaybeDefault})) + (HsQTvs + (NoExt) + [({ T15323.hs:5:19 } + (UserTyVar + (NoExt) + ({ T15323.hs:5:19 } + (Unqual + {OccName: v}))))]) + (Prefix) + (HsDataDefn + (NoExt) + (DataType) + ({ <no location info> } + []) + (Nothing) + (Nothing) + [({ T15323.hs:6:5-56 } + (ConDeclGADT + (NoExt) + [({ T15323.hs:6:5-14 } + (Unqual + {OccName: TestParens}))] + ({ T15323.hs:6:21-55 } + (True)) + (HsQTvs + (NoExt) + [({ T15323.hs:6:28 } + (UserTyVar + (NoExt) + ({ T15323.hs:6:28 } + (Unqual + {OccName: v}))))]) + (Just + ({ T15323.hs:6:32-37 } + [({ T15323.hs:6:32-37 } + (HsParTy + (NoExt) + ({ T15323.hs:6:33-36 } + (HsAppTy + (NoExt) + ({ T15323.hs:6:33-34 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ T15323.hs:6:33-34 } + (Unqual + {OccName: Eq})))) + ({ T15323.hs:6:36 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ T15323.hs:6:36 } + (Unqual + {OccName: v}))))))))])) + (PrefixCon + []) + ({ T15323.hs:6:42-55 } + (HsAppTy + (NoExt) + ({ T15323.hs:6:42-53 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ T15323.hs:6:42-53 } + (Unqual + {OccName: MaybeDefault})))) + ({ T15323.hs:6:55 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ T15323.hs:6:55 } + (Unqual + {OccName: v})))))) + (Nothing)))] + ({ <no location info> } + [])))))] + (Nothing) + (Nothing))) diff --git a/testsuite/tests/parser/should_compile/T8258.hs b/testsuite/tests/parser/should_compile/T8258.hs new file mode 100644 index 0000000000..18d6483973 --- /dev/null +++ b/testsuite/tests/parser/should_compile/T8258.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE GADTs #-} + +module T8258 where + +data T where diff --git a/testsuite/tests/parser/should_compile/all.T b/testsuite/tests/parser/should_compile/all.T index a9d6830701..d949f2b42e 100644 --- a/testsuite/tests/parser/should_compile/all.T +++ b/testsuite/tests/parser/should_compile/all.T @@ -41,7 +41,7 @@ test('read025', normal, compile, ['']) test('read026', normal, compile, ['']) test('read027', normal, compile, ['']) test('read028', normal, compile, ['']) -test('read029', expect_broken_for(10181, ['optasm', 'optllvm']), compile, ['']) +test('read029', normal, compile, ['']) test('read030', normal, compile, ['']) test('read031', normal, compile, ['']) test('read032', normal, compile, ['']) @@ -85,6 +85,9 @@ test('T2245', normal, compile, ['-fwarn-type-defaults']) test('T3303', [], multimod_compile, ['T3303', '-v0']) test('T3741', normal, compile, ['']) test('DoAndIfThenElse', normal, compile, ['']) +test('BlockArguments', normal, compile, ['']) +test('BlockArgumentsLambdaCase', normal, compile, ['']) +test('NoBlockArguments', normal, compile, ['']) test('NondecreasingIndentation', normal, compile, ['']) test('mc15', normal, compile, ['']) test('mc16', normal, compile, ['']) @@ -97,6 +100,7 @@ test('T7118', normal, compile, ['']) test('T7776', normal, compile, ['']) test('RdrNoStaticPointers01', [], compile, ['']) test('T5682', normal, compile, ['']) +test('T8258', normal, compile, ['']) test('T9723a', normal, compile, ['']) test('T9723b', normal, compile, ['']) test('T10188', normal, compile, ['']) @@ -108,3 +112,21 @@ test('DumpParsedAst', normal, compile, ['-dsuppress-uniques -ddump-parsed-a test('DumpRenamedAst', normal, compile, ['-dsuppress-uniques -ddump-rn-ast']) test('DumpTypecheckedAst', normal, compile, ['-dsuppress-uniques -ddump-tc-ast']) test('T13747', normal, compile, ['']) +test('T14189', normal, compile, ['-dsuppress-uniques -ddump-rn-ast']) +test('T13986', normal, compile, ['']) +test('T10855', normal, compile, ['']) +test('T15139', normal, compile, ['-Wincomplete-patterns -fdiagnostics-show-caret']) +test('T15323', normal, compile, ['-dsuppress-uniques -ddump-parsed-ast']) + +def only_MG_loc(x): + """ + Only compares the location embedded inside the MatchGroup, which has the form + (MG + (NoExt) + ({ <location> + """ + ls = x.split("\n") + mgLocs = (loc.strip() for (mg,loc) in zip(ls,ls[2:]) + if mg.strip().startswith("(MG")) + return '\n'.join(mgLocs) +test('T15279', normalise_errmsg_fun(only_MG_loc), compile, ['']) diff --git a/testsuite/tests/parser/should_fail/InfixAppPatErr.hs b/testsuite/tests/parser/should_fail/InfixAppPatErr.hs new file mode 100644 index 0000000000..5a56f711eb --- /dev/null +++ b/testsuite/tests/parser/should_fail/InfixAppPatErr.hs @@ -0,0 +1,5 @@ +main = do + f $ do + a <- return 3 + c <- do + return 5 diff --git a/testsuite/tests/parser/should_fail/InfixAppPatErr.stderr b/testsuite/tests/parser/should_fail/InfixAppPatErr.stderr new file mode 100644 index 0000000000..69839e3920 --- /dev/null +++ b/testsuite/tests/parser/should_fail/InfixAppPatErr.stderr @@ -0,0 +1,4 @@ + +InfixAppPatErr.hs:2:3: error: + Parse error in pattern: f $ do a <- return 3 c + Possibly caused by a missing 'do'? diff --git a/testsuite/tests/parser/should_fail/NoBlockArgumentsFail.hs b/testsuite/tests/parser/should_fail/NoBlockArgumentsFail.hs new file mode 100644 index 0000000000..6c791b0f95 --- /dev/null +++ b/testsuite/tests/parser/should_fail/NoBlockArgumentsFail.hs @@ -0,0 +1,7 @@ +module NoBlockArgumentsFail where + +import Control.Monad + +foo :: IO () +foo = when True do + return () diff --git a/testsuite/tests/parser/should_fail/NoBlockArgumentsFail.stderr b/testsuite/tests/parser/should_fail/NoBlockArgumentsFail.stderr new file mode 100644 index 0000000000..813271bdb9 --- /dev/null +++ b/testsuite/tests/parser/should_fail/NoBlockArgumentsFail.stderr @@ -0,0 +1,6 @@ + +NoBlockArgumentsFail.hs:6:17: error: + Unexpected do block in function application: + do return () + You could write it with parentheses + Or perhaps you meant to enable BlockArguments? diff --git a/testsuite/tests/parser/should_fail/NoBlockArgumentsFail2.hs b/testsuite/tests/parser/should_fail/NoBlockArgumentsFail2.hs new file mode 100644 index 0000000000..752df24081 --- /dev/null +++ b/testsuite/tests/parser/should_fail/NoBlockArgumentsFail2.hs @@ -0,0 +1,6 @@ +module NoBlockArgumentsFail2 where + +import Control.Monad + +foo :: IO () +foo = forM [1 .. 10] \x -> print x diff --git a/testsuite/tests/parser/should_fail/NoBlockArgumentsFail2.stderr b/testsuite/tests/parser/should_fail/NoBlockArgumentsFail2.stderr new file mode 100644 index 0000000000..0361369774 --- /dev/null +++ b/testsuite/tests/parser/should_fail/NoBlockArgumentsFail2.stderr @@ -0,0 +1,6 @@ + +NoBlockArgumentsFail2.hs:6:22: error: + Unexpected lambda expression in function application: + \ x -> print x + You could write it with parentheses + Or perhaps you meant to enable BlockArguments? diff --git a/testsuite/tests/parser/should_fail/NoBlockArgumentsFail3.hs b/testsuite/tests/parser/should_fail/NoBlockArgumentsFail3.hs new file mode 100644 index 0000000000..91bd6e5dec --- /dev/null +++ b/testsuite/tests/parser/should_fail/NoBlockArgumentsFail3.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE LambdaCase #-} +module NoBlockArgumentsFail3 where + +import Control.Monad + +foo :: IO () +foo = forM [1 .. 10] \case + Just 3 -> print x diff --git a/testsuite/tests/parser/should_fail/NoBlockArgumentsFail3.stderr b/testsuite/tests/parser/should_fail/NoBlockArgumentsFail3.stderr new file mode 100644 index 0000000000..e285e6ea72 --- /dev/null +++ b/testsuite/tests/parser/should_fail/NoBlockArgumentsFail3.stderr @@ -0,0 +1,6 @@ + +NoBlockArgumentsFail3.hs:7:22: error: + Unexpected lambda-case expression in function application: + \case Just 3 -> print x + You could write it with parentheses + Or perhaps you meant to enable BlockArguments? diff --git a/testsuite/tests/parser/should_fail/NoNumericUnderscores0.hs b/testsuite/tests/parser/should_fail/NoNumericUnderscores0.hs new file mode 100644 index 0000000000..5e6821124a --- /dev/null +++ b/testsuite/tests/parser/should_fail/NoNumericUnderscores0.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE NoNumericUnderscores #-} + +-- Test for NumericUnderscores extension. +-- See Trac #14473 +-- This is a testcase for integer literal +-- in NO NumericUnderscores extension. + +module NoNumericUnderscores0 where + +f :: Int -> () +f 1_000 = () +f _ = () diff --git a/testsuite/tests/parser/should_fail/NoNumericUnderscores0.stderr b/testsuite/tests/parser/should_fail/NoNumericUnderscores0.stderr new file mode 100644 index 0000000000..af59581c14 --- /dev/null +++ b/testsuite/tests/parser/should_fail/NoNumericUnderscores0.stderr @@ -0,0 +1,3 @@ + +NoNumericUnderscores0.hs:11:3: error: + Use NumericUnderscores to allow underscores in integer literals diff --git a/testsuite/tests/parser/should_fail/NoNumericUnderscores1.hs b/testsuite/tests/parser/should_fail/NoNumericUnderscores1.hs new file mode 100644 index 0000000000..017f20528b --- /dev/null +++ b/testsuite/tests/parser/should_fail/NoNumericUnderscores1.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE NoNumericUnderscores #-} + +-- Test for NumericUnderscores extension. +-- See Trac #14473 +-- This is a testcase for floating literal +-- in NO NumericUnderscores extension. + +module NoNumericUnderscores1 where + +f :: Float -> () +f 1_000.0_1 = () +f _ = () diff --git a/testsuite/tests/parser/should_fail/NoNumericUnderscores1.stderr b/testsuite/tests/parser/should_fail/NoNumericUnderscores1.stderr new file mode 100644 index 0000000000..0dfbaa409e --- /dev/null +++ b/testsuite/tests/parser/should_fail/NoNumericUnderscores1.stderr @@ -0,0 +1,3 @@ + +NoNumericUnderscores1.hs:11:3: error: + Use NumericUnderscores to allow underscores in floating literals diff --git a/testsuite/tests/parser/should_fail/NumericUnderscoresFail0.hs b/testsuite/tests/parser/should_fail/NumericUnderscoresFail0.hs new file mode 100644 index 0000000000..1f04184365 --- /dev/null +++ b/testsuite/tests/parser/should_fail/NumericUnderscoresFail0.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE NumericUnderscores #-} + +-- Test for NumericUnderscores extension. +-- See Trac #14473 +-- This is a testcase for invalid case of NumericUnderscores. + +main :: IO () +main = do + print [ + -- integer + 1000000_, + _1000000 + ] diff --git a/testsuite/tests/parser/should_fail/NumericUnderscoresFail0.stderr b/testsuite/tests/parser/should_fail/NumericUnderscoresFail0.stderr new file mode 100644 index 0000000000..8c872575a5 --- /dev/null +++ b/testsuite/tests/parser/should_fail/NumericUnderscoresFail0.stderr @@ -0,0 +1,4 @@ +NumericUnderscoresFail0.hs:9:5: error: +NumericUnderscoresFail0.hs:11:13: error: +NumericUnderscoresFail0.hs:11:20: error: +NumericUnderscoresFail0.hs:12:13: error: diff --git a/testsuite/tests/parser/should_fail/NumericUnderscoresFail1.hs b/testsuite/tests/parser/should_fail/NumericUnderscoresFail1.hs new file mode 100644 index 0000000000..0a6a3051d6 --- /dev/null +++ b/testsuite/tests/parser/should_fail/NumericUnderscoresFail1.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE NumericUnderscores #-} + +-- Test for NumericUnderscores extension. +-- See Trac #14473 +-- This is a testcase for invalid case of NumericUnderscores. + +main :: IO () +main = do + print [ + -- float + 0_.0001, + _0.0001, + 0.0001_, + 0._0001, + + -- float with exponent + 1e_+23, + 1e+23_, + 1e+_23 + ] diff --git a/testsuite/tests/parser/should_fail/NumericUnderscoresFail1.stderr b/testsuite/tests/parser/should_fail/NumericUnderscoresFail1.stderr new file mode 100644 index 0000000000..e1c91de091 --- /dev/null +++ b/testsuite/tests/parser/should_fail/NumericUnderscoresFail1.stderr @@ -0,0 +1,7 @@ +NumericUnderscoresFail1.hs:11:14: error: +NumericUnderscoresFail1.hs:13:19: error: +NumericUnderscoresFail1.hs:14:15: error: +NumericUnderscoresFail1.hs:17:14: error: Variable not in scope: e_ +NumericUnderscoresFail1.hs:18:18: error: +NumericUnderscoresFail1.hs:19:14: error: Variable not in scope: e +NumericUnderscoresFail1.hs:19:16: error: diff --git a/testsuite/tests/parser/should_fail/ParserNoLambdaCase.stderr b/testsuite/tests/parser/should_fail/ParserNoLambdaCase.stderr index 5eb8b539a3..24d5cfc168 100644 --- a/testsuite/tests/parser/should_fail/ParserNoLambdaCase.stderr +++ b/testsuite/tests/parser/should_fail/ParserNoLambdaCase.stderr @@ -1,2 +1,2 @@ - -ParserNoLambdaCase.hs:3:6: error: parse error on input ‘case’ +ParserNoLambdaCase.hs:3:6: + Illegal lambda-case (use -XLambdaCase) diff --git a/testsuite/tests/parser/should_fail/T13450.hs b/testsuite/tests/parser/should_fail/T13450.hs new file mode 100644 index 0000000000..b36cca0719 --- /dev/null +++ b/testsuite/tests/parser/should_fail/T13450.hs @@ -0,0 +1,4 @@ +module T13450 where + +example = foo + where foo = '' diff --git a/testsuite/tests/parser/should_fail/T13450.stderr b/testsuite/tests/parser/should_fail/T13450.stderr new file mode 100644 index 0000000000..6e0beb32cc --- /dev/null +++ b/testsuite/tests/parser/should_fail/T13450.stderr @@ -0,0 +1,4 @@ + +T13450.hs:4:15: error: + Parser error on `''` + Character literals may not be empty diff --git a/testsuite/tests/parser/should_fail/T13450TH.hs b/testsuite/tests/parser/should_fail/T13450TH.hs new file mode 100644 index 0000000000..c851049582 --- /dev/null +++ b/testsuite/tests/parser/should_fail/T13450TH.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE TemplateHaskell #-} + +module T13450TH where + +example = foo + where foo = '' diff --git a/testsuite/tests/parser/should_fail/T13450TH.stderr b/testsuite/tests/parser/should_fail/T13450TH.stderr new file mode 100644 index 0000000000..11733c5c91 --- /dev/null +++ b/testsuite/tests/parser/should_fail/T13450TH.stderr @@ -0,0 +1,6 @@ + +T13450TH.hs:6:15: error: + Parser error on `''` + Character literals may not be empty + Or perhaps you intended to use quotation syntax of TemplateHaskell, + but the type variable or constructor is missing diff --git a/testsuite/tests/parser/should_fail/T14588.hs b/testsuite/tests/parser/should_fail/T14588.hs new file mode 100644 index 0000000000..8a0bcecd7b --- /dev/null +++ b/testsuite/tests/parser/should_fail/T14588.hs @@ -0,0 +1,3 @@ +module T14588 where + +main = print (let !x = 1 + 2 in x) diff --git a/testsuite/tests/parser/should_fail/T14588.stderr b/testsuite/tests/parser/should_fail/T14588.stderr new file mode 100644 index 0000000000..cb64103814 --- /dev/null +++ b/testsuite/tests/parser/should_fail/T14588.stderr @@ -0,0 +1,4 @@ + +T14588.hs:3:19: error: + Illegal bang-pattern (use BangPatterns): + ! x diff --git a/testsuite/tests/parser/should_fail/T14740.hs b/testsuite/tests/parser/should_fail/T14740.hs new file mode 100644 index 0000000000..b56687f051 --- /dev/null +++ b/testsuite/tests/parser/should_fail/T14740.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE UnboxedTuples #-} + +module T14740 where + +x :: ((##)) => () +x = () diff --git a/testsuite/tests/parser/should_fail/T14740.stderr b/testsuite/tests/parser/should_fail/T14740.stderr new file mode 100644 index 0000000000..8827873e25 --- /dev/null +++ b/testsuite/tests/parser/should_fail/T14740.stderr @@ -0,0 +1,4 @@ + +T14740.hs:5:7: + Expecting a lifted type, but ‘(# #)’ is unlifted + In the type signature: x :: ((# #)) => () diff --git a/testsuite/tests/parser/should_fail/T15053.hs b/testsuite/tests/parser/should_fail/T15053.hs new file mode 100644 index 0000000000..44154a48c0 --- /dev/null +++ b/testsuite/tests/parser/should_fail/T15053.hs @@ -0,0 +1,3 @@ +{-# OPTIONS_GHC -O1 } +" + #-} diff --git a/testsuite/tests/parser/should_fail/T15053.stderr b/testsuite/tests/parser/should_fail/T15053.stderr new file mode 100644 index 0000000000..0544327c5e --- /dev/null +++ b/testsuite/tests/parser/should_fail/T15053.stderr @@ -0,0 +1,5 @@ +T15053.hs:1:16: + Error while parsing OPTIONS_GHC pragma. + Expecting whitespace-separated list of GHC options. + E.g. {-# OPTIONS_GHC -Wall -O2 #-} + Input was: " -O1 }/n/"/n " diff --git a/testsuite/tests/parser/should_fail/T15209.hs b/testsuite/tests/parser/should_fail/T15209.hs new file mode 100644 index 0000000000..1679d80ba6 --- /dev/null +++ b/testsuite/tests/parser/should_fail/T15209.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE GADTs, TypeOperators #-} +module T15209 where + +import GHC.Prim + +foo :: a ~# Int -> () +foo = () diff --git a/testsuite/tests/parser/should_fail/T15209.stderr b/testsuite/tests/parser/should_fail/T15209.stderr new file mode 100644 index 0000000000..9d1e151cf2 --- /dev/null +++ b/testsuite/tests/parser/should_fail/T15209.stderr @@ -0,0 +1,2 @@ + +T15209.hs:6:10: error: Not in scope: type constructor or class ‘~#’ diff --git a/testsuite/tests/parser/should_fail/T3811c.stderr b/testsuite/tests/parser/should_fail/T3811c.stderr index 4a371165fb..dd219184e7 100644 --- a/testsuite/tests/parser/should_fail/T3811c.stderr +++ b/testsuite/tests/parser/should_fail/T3811c.stderr @@ -1,2 +1,5 @@ -T3811c.hs:6:10: Malformed instance: !Show D +T3811c.hs:6:10: error: + • Unexpected strictness annotation: !Show + strictness annotation cannot appear nested inside a type + • In the instance declaration for ‘!Show D’ diff --git a/testsuite/tests/parser/should_fail/T7848.hs b/testsuite/tests/parser/should_fail/T7848.hs index 25f0af7ee0..920f28e8c9 100644 --- a/testsuite/tests/parser/should_fail/T7848.hs +++ b/testsuite/tests/parser/should_fail/T7848.hs @@ -8,4 +8,4 @@ x (+) ((&)@z) ((:&&) a b) (c :&& d) (e `A` f) (A g h) = y y _ = (&) {-# INLINE (&) #-} {-# SPECIALIZE (&) :: a #-} - (&) = x + (&) = 'c' diff --git a/testsuite/tests/parser/should_fail/T7848.stderr b/testsuite/tests/parser/should_fail/T7848.stderr index 95ac7374ef..413920dbe6 100644 --- a/testsuite/tests/parser/should_fail/T7848.stderr +++ b/testsuite/tests/parser/should_fail/T7848.stderr @@ -1,13 +1,7 @@ -T7848.hs:6:1: error: - • Occurs check: cannot construct the infinite type: - t ~ p0 -> p1 -> A -> A -> A -> A -> p2 -> t - • Relevant bindings include x :: t (bound at T7848.hs:6:1) - T7848.hs:10:9: error: - • Couldn't match expected type ‘t’ with actual type ‘a’ - because type variable ‘a’ would escape its scope - This (rigid, skolem) type variable is bound by + • Couldn't match expected type ‘Char’ with actual type ‘a’ + ‘a’ is a rigid type variable bound by the type signature for: (&) :: forall a. a at T7848.hs:10:9-35 @@ -20,5 +14,4 @@ T7848.hs:10:9: error: y _ = (&) {-# INLINE (&) #-} {-# SPECIALIZE (&) :: a #-} - (&) = x - • Relevant bindings include x :: t (bound at T7848.hs:6:1) + (&) = 'c' diff --git a/testsuite/tests/parser/should_fail/T8258NoGADTs.hs b/testsuite/tests/parser/should_fail/T8258NoGADTs.hs new file mode 100644 index 0000000000..1080233bcd --- /dev/null +++ b/testsuite/tests/parser/should_fail/T8258NoGADTs.hs @@ -0,0 +1,3 @@ +module T8258NoGADTs where + +data T where diff --git a/testsuite/tests/parser/should_fail/T8258NoGADTs.stderr b/testsuite/tests/parser/should_fail/T8258NoGADTs.stderr new file mode 100644 index 0000000000..35f5306274 --- /dev/null +++ b/testsuite/tests/parser/should_fail/T8258NoGADTs.stderr @@ -0,0 +1,5 @@ + +T8258NoGADTs.hs:3:8: error: + Illegal keyword 'where' in data declaration + Perhaps you intended to use GADTs or a similar language + extension to enable syntax: data T where diff --git a/testsuite/tests/parser/should_fail/all.T b/testsuite/tests/parser/should_fail/all.T index abe3da9775..960144c9cb 100644 --- a/testsuite/tests/parser/should_fail/all.T +++ b/testsuite/tests/parser/should_fail/all.T @@ -35,7 +35,8 @@ test('readFail028', normal, compile_fail, ['']) test('readFail029', normal, compile_fail, ['']) test('readFail030', normal, compile_fail, ['']) test('readFail031', normal, compile_fail, ['']) -test('readFail032', expect_broken(314), compile_fail, ['-cpp']) +test('readFail032', when(opsys('darwin'), expect_broken(15662)), + compile_fail, ['-cpp']) test('readFail033', normal, compile_fail, ['']) test('readFail034', normal, compile_fail, ['']) test('readFail035', normal, compile_fail, ['']) @@ -50,6 +51,8 @@ test('readFail043', normal, compile_fail, ['']) test('readFail044', normal, compile_fail, ['']) test('readFail046', normal, compile_fail, ['']) test('readFail047', normal, compile_fail, ['']) +test('readFail048', when(opsys('darwin'), expect_broken(15662)), + compile_fail, ['-cpp -haddock']) test('T3095', normal, compile_fail, ['']) test('T3153', normal, compile_fail, ['']) test('T3751', normal, compile_fail, ['']) @@ -69,6 +72,9 @@ test('T3811f', normal, compile_fail, ['']) test('T3811g', normal, compile_fail, ['']) test('NoDoAndIfThenElse', normal, compile_fail, ['']) test('NoPatternSynonyms', normal, compile_fail, ['']) +test('NoBlockArgumentsFail', normal, compile_fail, ['']) +test('NoBlockArgumentsFail2', normal, compile_fail, ['']) +test('NoBlockArgumentsFail3', normal, compile_fail, ['']) test('NondecreasingIndentationFail', normal, compile_fail, ['']) test('readFailTraditionalRecords1', normal, compile_fail, ['']) test('readFailTraditionalRecords2', normal, compile_fail, ['']) @@ -84,6 +90,7 @@ test('T5425', normal, compile_fail, ['']) test('T984', normal, compile_fail, ['']) test('T7848', normal, compile_fail, ['-dppr-user-length=100']) test('ExportCommaComma', normal, compile_fail, ['']) +test('T8258NoGADTs', normal, compile_fail, ['']) test('T8430', literate, compile_fail, ['']) test('T8431', compile_timeout_multiplier(0.05), compile_fail, ['-XAlternativeLayoutRule']) @@ -102,3 +109,23 @@ test('T8501a', normal, compile_fail, ['']) test('T8501b', normal, compile_fail, ['']) test('T8501c', normal, compile_fail, ['']) test('T12610', normal, compile_fail, ['']) +test('T13450', normal, compile_fail, ['']) +test('T13450TH', normal, compile_fail, ['']) +test('T14588', normal, compile_fail, ['']) +test('T14740', normal, compile_fail, ['']) +test('T15209', normal, compile_fail, ['']) + +test('NoNumericUnderscores0', normal, compile_fail, ['']) +test('NoNumericUnderscores1', normal, compile_fail, ['']) +test('NumericUnderscoresFail0', + grep_errmsg(r'^NumericUnderscoresFail0.hs:'), compile_fail, ['']) +test('NumericUnderscoresFail1', + grep_errmsg(r'^NumericUnderscoresFail1.hs:'), compile_fail, ['']) + +test('InfixAppPatErr', normal, compile_fail, ['']) + +test('typeops_A', normal, compile_fail, ['']) +test('typeops_B', normal, compile_fail, ['']) +test('typeops_C', normal, compile_fail, ['']) +test('typeops_D', normal, compile_fail, ['']) +test('T15053', normal, compile_fail, ['']) diff --git a/testsuite/tests/parser/should_fail/readFail032.hs b/testsuite/tests/parser/should_fail/readFail032.hs index dec758a16f..93e7181033 100644 --- a/testsuite/tests/parser/should_fail/readFail032.hs +++ b/testsuite/tests/parser/should_fail/readFail032.hs @@ -1,4 +1,3 @@ - -- Test for trac #314 {- @@ -8,15 +7,19 @@ up some lines - This - uses - up - some - lines + The + following + pragmas + should + not + be + parsed */ +# 23 +#pragma + -} module ShouldFail where -type_error = "Type error on line 21":"Type error on line 21" - +type_error = "Type error on line 25":"Type error on line 25" diff --git a/testsuite/tests/parser/should_fail/readFail032.stderr b/testsuite/tests/parser/should_fail/readFail032.stderr index 95852c5bbd..7cd106d69a 100644 --- a/testsuite/tests/parser/should_fail/readFail032.stderr +++ b/testsuite/tests/parser/should_fail/readFail032.stderr @@ -1,8 +1,11 @@ -readFail032.hs:21:38: - Couldn't match expected type `[Char]' with actual type `Char' +readFail032.hs:25:38: + Couldn't match type ‘Char’ with ‘[Char]’ Expected type: [[Char]] Actual type: [Char] - In the second argument of `(:)', namely `"Type error on line 21"' - In the expression: - "Type error on line 21" : "Type error on line 21" + In the second argument of ‘(:)’, namely ‘"Type error on line 25"’ + In the expression: + "Type error on line 25" : "Type error on line 25" + In an equation for ‘type_error’: + type_error = "Type error on line 25" : "Type error on line 25" + diff --git a/testsuite/tests/parser/should_fail/readFail036.hs b/testsuite/tests/parser/should_fail/readFail036.hs index 2bb23149dd..15afd980f8 100644 --- a/testsuite/tests/parser/should_fail/readFail036.hs +++ b/testsuite/tests/parser/should_fail/readFail036.hs @@ -1,5 +1,5 @@ - module Foo where -data Foo (a :: *) = Foo a +import Data.Kind (Type) +data Foo (a :: Type) = Foo a diff --git a/testsuite/tests/parser/should_fail/readFail036.stderr b/testsuite/tests/parser/should_fail/readFail036.stderr index 0d22eb8363..a66afacacf 100644 --- a/testsuite/tests/parser/should_fail/readFail036.stderr +++ b/testsuite/tests/parser/should_fail/readFail036.stderr @@ -1,5 +1,5 @@ -readFail036.hs:4:16: - Illegal kind signature: ‘*’ +readFail036.hs:5:16: error: + Illegal kind signature: ‘Type’ Perhaps you intended to use KindSignatures In the data type declaration for ‘Foo’ diff --git a/testsuite/tests/parser/should_fail/readFail037.stderr b/testsuite/tests/parser/should_fail/readFail037.stderr index 6fcd2db206..6b317eb051 100644 --- a/testsuite/tests/parser/should_fail/readFail037.stderr +++ b/testsuite/tests/parser/should_fail/readFail037.stderr @@ -1,5 +1,5 @@ -readFail037.hs:4:1: - Too many parameters for class ‘Foo’ - (Use MultiParamTypeClasses to allow multi-parameter classes) - In the class declaration for ‘Foo’ +readFail037.hs:4:1: error: + • Too many parameters for class ‘Foo’ + (Enable MultiParamTypeClasses to allow multi-parameter classes) + • In the class declaration for ‘Foo’ diff --git a/testsuite/tests/parser/should_fail/readFail041.stderr b/testsuite/tests/parser/should_fail/readFail041.stderr index c5b28a6f0f..028b96510b 100644 --- a/testsuite/tests/parser/should_fail/readFail041.stderr +++ b/testsuite/tests/parser/should_fail/readFail041.stderr @@ -1,5 +1,5 @@ -readFail041.hs:6:1: - Fundeps in class ‘Foo’ - (Use FunctionalDependencies to allow fundeps) - In the class declaration for ‘Foo’ +readFail041.hs:6:1: error: + • Fundeps in class ‘Foo’ + (Enable FunctionalDependencies to allow fundeps) + • In the class declaration for ‘Foo’ diff --git a/testsuite/tests/parser/should_fail/readFail048.hs b/testsuite/tests/parser/should_fail/readFail048.hs new file mode 100644 index 0000000000..2985e5e66f --- /dev/null +++ b/testsuite/tests/parser/should_fail/readFail048.hs @@ -0,0 +1,25 @@ +-- Test for trac #314 + +{-| +/* + This + uses + up + some + lines + The + following + pragmas + should + not + be + parsed + */ +# 23 +#pragma + +-} + +module ShouldFail where + +type_error = "Type error on line 25":"Type error on line 25" diff --git a/testsuite/tests/parser/should_fail/readFail048.stderr b/testsuite/tests/parser/should_fail/readFail048.stderr new file mode 100644 index 0000000000..62276db0c9 --- /dev/null +++ b/testsuite/tests/parser/should_fail/readFail048.stderr @@ -0,0 +1,11 @@ + +readFail048.hs:25:38: + Couldn't match type ‘Char’ with ‘[Char]’ + Expected type: [[Char]] + Actual type: [Char] + In the second argument of ‘(:)’, namely ‘"Type error on line 25"’ + In the expression: + "Type error on line 25" : "Type error on line 25" + In an equation for ‘type_error’: + type_error = "Type error on line 25" : "Type error on line 25" + diff --git a/testsuite/tests/parser/should_fail/typeops_A.hs b/testsuite/tests/parser/should_fail/typeops_A.hs new file mode 100644 index 0000000000..abd7f528c6 --- /dev/null +++ b/testsuite/tests/parser/should_fail/typeops_A.hs @@ -0,0 +1 @@ +type X = 1 + diff --git a/testsuite/tests/parser/should_fail/typeops_A.stderr b/testsuite/tests/parser/should_fail/typeops_A.stderr new file mode 100644 index 0000000000..69f7aac6be --- /dev/null +++ b/testsuite/tests/parser/should_fail/typeops_A.stderr @@ -0,0 +1,2 @@ + +typeops_A.hs:1:12: error: Operator applied to too few arguments: + diff --git a/testsuite/tests/parser/should_fail/typeops_B.hs b/testsuite/tests/parser/should_fail/typeops_B.hs new file mode 100644 index 0000000000..ac65f872de --- /dev/null +++ b/testsuite/tests/parser/should_fail/typeops_B.hs @@ -0,0 +1 @@ +type X = + 1 diff --git a/testsuite/tests/parser/should_fail/typeops_B.stderr b/testsuite/tests/parser/should_fail/typeops_B.stderr new file mode 100644 index 0000000000..030516a27f --- /dev/null +++ b/testsuite/tests/parser/should_fail/typeops_B.stderr @@ -0,0 +1,2 @@ + +typeops_B.hs:1:10: error: Operator applied to too few arguments: + diff --git a/testsuite/tests/parser/should_fail/typeops_C.hs b/testsuite/tests/parser/should_fail/typeops_C.hs new file mode 100644 index 0000000000..e55838934a --- /dev/null +++ b/testsuite/tests/parser/should_fail/typeops_C.hs @@ -0,0 +1 @@ +type X = 1 + + 2 diff --git a/testsuite/tests/parser/should_fail/typeops_C.stderr b/testsuite/tests/parser/should_fail/typeops_C.stderr new file mode 100644 index 0000000000..280323bb67 --- /dev/null +++ b/testsuite/tests/parser/should_fail/typeops_C.stderr @@ -0,0 +1,2 @@ + +typeops_C.hs:1:12: error: Operator applied to too few arguments: + diff --git a/testsuite/tests/parser/should_fail/typeops_D.hs b/testsuite/tests/parser/should_fail/typeops_D.hs new file mode 100644 index 0000000000..655b2f15f0 --- /dev/null +++ b/testsuite/tests/parser/should_fail/typeops_D.hs @@ -0,0 +1 @@ +type X = + diff --git a/testsuite/tests/parser/should_fail/typeops_D.stderr b/testsuite/tests/parser/should_fail/typeops_D.stderr new file mode 100644 index 0000000000..0ce7e29559 --- /dev/null +++ b/testsuite/tests/parser/should_fail/typeops_D.stderr @@ -0,0 +1,2 @@ + +typeops_D.hs:1:10: error: Operator applied to too few arguments: + diff --git a/testsuite/tests/parser/should_run/HexFloatLiterals.hs b/testsuite/tests/parser/should_run/HexFloatLiterals.hs new file mode 100644 index 0000000000..5e71ac340d --- /dev/null +++ b/testsuite/tests/parser/should_run/HexFloatLiterals.hs @@ -0,0 +1,16 @@ +{-# Language HexFloatLiterals #-} + +import Numeric(showHFloat) + +main :: IO () +main = + do print [ 0xF.0 + , 0xF.1, 0xF.01 + , 0xF1p-4, 0xF01p-8 + , 0x0.F1p4, 0x0.00F01p12 + ] + + mapM_ putStrLn [ showHFloat (212.21 :: Double) "" + , showHFloat (-12.76 :: Float) "" + , showHFloat (-0 :: Double) "" + ] diff --git a/testsuite/tests/parser/should_run/HexFloatLiterals.stdout b/testsuite/tests/parser/should_run/HexFloatLiterals.stdout new file mode 100644 index 0000000000..20ce2a245a --- /dev/null +++ b/testsuite/tests/parser/should_run/HexFloatLiterals.stdout @@ -0,0 +1,4 @@ +[15.0,15.0625,15.00390625,15.0625,15.00390625,15.0625,15.00390625] +0x1.a86b851eb851fp7 +-0x1.9851ecp3 +-0x0p+0 diff --git a/testsuite/tests/parser/should_run/NumericUnderscores0.hs b/testsuite/tests/parser/should_run/NumericUnderscores0.hs new file mode 100644 index 0000000000..7aefce95c6 --- /dev/null +++ b/testsuite/tests/parser/should_run/NumericUnderscores0.hs @@ -0,0 +1,101 @@ +{-# LANGUAGE NumericUnderscores #-} +{-# LANGUAGE BinaryLiterals #-} +{-# LANGUAGE HexFloatLiterals #-} +{-# LANGUAGE NegativeLiterals #-} + +-- Test for NumericUnderscores extension. +-- See Trac #14473 +-- This is a testcase for boxed literals. + +main :: IO () +main = do + -- Each case corresponds to the definition of Lexer.x + -- + -- Normal integral literals + -- decimal + print [ 1_000_000 == 1000000, + 1__0 == 10, + 299_792_458 == 299792458, + 8_04_1 == 8041, + 2017_12_31 == 20171231 + ] + + -- binary + print [ 0b01_0000_0000 == 0b0100000000, + 0b1_11_01_0000_0_111 == 0b1110100000111, + 0b1100_1011__1110_1111__0101_0011 == + 0b110010111110111101010011 + ] + + -- octal + print [ 0o1_000_000 == 0o1000000, + 0O1__0 == 0O10 + ] + + -- hexadecimal + print [ 0x1_000_000 == 0x1000000, + 0x1__0 == 0x10, + 0xff_00_00 == 0xff0000, + 0X3fff_ffff == 0x3fffffff + ] + + -- negative decimal + print [ -1_0 == -10 + ] + + -- negative binary + print [ -0b1_0 == -0b10 + ] + + -- negative octal + print [ -0o1_0 == -0o10 + ] + + -- negative hexadecimal + print [ -0x1_0 == -0x10 + ] + + ---- Normal rational literals + -- float + print [ 3.141_592_653_589_793 == 3.141592653589793, + 96_485.332_89 == 96485.33289, + 6.022_140_857e+23 == 6.022140857e+23 + ] + + -- negative float + print [ -1_0.0_1 == -10.01, + -1_0e+2 == -10e+2, + -1_0.0_1e+3 == -10.01e+3 + ] + + -- hexadecimal float + print [ 0xF_F.1F == 0xFF.1F, + 0xF_01p-8 == 0xF01p-8, + 0x0.F_1p4 == 0x0.F1p4 + ] + + -- negative hexadecimal float + print [ -0xF_F.F == -0xFF.F, + -0xF_01p-1 == -0xF01p-1, + -0x0.F_1p1 == -0x0.F1p1 + ] + + -- Additional testcase + -- + -- Validity + print [ 0.000_1 == 0.0001, + 1_0.000_1 == 10.0001, + 1e+23 == 1e+23, + 1_e+23 == 1e+23, + 1__e+23 == 1e+23, + 1.0_e+23 == 1.0e+23, + 1.0_e+2_3 == 1.0e+23, + 1_e23 == 1e23, + 1_e-23 == 1e-23, + 1_0_e23 == 10e23, + 1_0_e-23 == 10e-23, + 0b_01 == 0b01, + 0b__11 == 0b11, + 0x_ff == 0xff, + 0x__ff == 0xff + ] diff --git a/testsuite/tests/parser/should_run/NumericUnderscores0.stdout b/testsuite/tests/parser/should_run/NumericUnderscores0.stdout new file mode 100644 index 0000000000..76f19a8ad9 --- /dev/null +++ b/testsuite/tests/parser/should_run/NumericUnderscores0.stdout @@ -0,0 +1,13 @@ +[True,True,True,True,True] +[True,True,True] +[True,True] +[True,True,True,True] +[True] +[True] +[True] +[True] +[True,True,True] +[True,True,True] +[True,True,True] +[True,True,True] +[True,True,True,True,True,True,True,True,True,True,True,True,True,True,True] diff --git a/testsuite/tests/parser/should_run/NumericUnderscores1.hs b/testsuite/tests/parser/should_run/NumericUnderscores1.hs new file mode 100644 index 0000000000..b9d0dca725 --- /dev/null +++ b/testsuite/tests/parser/should_run/NumericUnderscores1.hs @@ -0,0 +1,88 @@ +{-# LANGUAGE NumericUnderscores #-} +{-# LANGUAGE BinaryLiterals #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE NegativeLiterals #-} + +-- Test for NumericUnderscores extension. +-- See Trac #14473 +-- This is a testcase for unboxed literals. + +import GHC.Types + +main :: IO () +main = do + -- Each case corresponds to the definition of Lexer.x + -- + -- Unboxed ints and words + -- decimal int + print [ (I# 1_000_000#) == 1000000, + (I# 299_792_458#) == 299792458 + ] + + -- binary int + print [ (I# 0b01_0000_0000#) == 0b0100000000, + (I# 0b1_11_01_0000_0_111#) == 0b1110100000111 + ] + + -- octal int + print [ (I# 0o1_000_000#) == 0o1000000, + (I# 0O1__0#) == 0O10 + ] + + -- hexadecimal int + print [ (I# 0x1_000_000#) == 0x1000000, + (I# 0X3fff_ffff#) == 0x3fffffff + ] + + -- negative decimal int + print [ (I# -1_000_000#) == -1000000 + ] + + -- negative binary int + print [ (I# -0b01_0000_0000#) == -0b0100000000 + ] + + -- negative octal int + print [ (I# -0o1_000_000#) == -0o1000000 + ] + + -- negative hexadecimal int + print [ (I# -0x1_000_000#) == -0x1000000 + ] + + -- decimal word + print [ (W# 1_000_000##) == 1000000, + (W# 299_792_458##) == 299792458 + ] + + -- binary word + print [ (W# 0b1_0##) == 0b10 + ] + + -- octal word + print [ (W# 0o1_0##) == 0o10 + ] + + -- hexadecimal word + print [ (W# 0x1_0##) == 0x10 + ] + + -- Unboxed floats and doubles + -- float + print [ (F# 3.141_592_653_589_793#) == 3.141592653589793, + (F# 3_14e-2#) == 314e-2, + (F# 96_485.332_89#) == 96485.33289, + (F# 6.022_140_857e+23#) == 6.022140857e+23, + (F# -3.141_592#) == -3.141592, + (F# -3_14e-2#) == -314e-2, + (F# -6.022_140e+23#) == -6.022140e+23 + ] + + -- double + print [ (D# 3_14e-2##) == 314e-2, + (D# 96_485.332_89##) == 96485.33289, + (D# 6.022_140_857e+23##) == 6.022140857e+23, + (D# -3.141_592##) == -3.141592, + (D# -3_14e-2##) == -314e-2, + (D# -6.022_140e+23##) == -6.022140e+23 + ] diff --git a/testsuite/tests/parser/should_run/NumericUnderscores1.stdout b/testsuite/tests/parser/should_run/NumericUnderscores1.stdout new file mode 100644 index 0000000000..bddde5bccb --- /dev/null +++ b/testsuite/tests/parser/should_run/NumericUnderscores1.stdout @@ -0,0 +1,14 @@ +[True,True] +[True,True] +[True,True] +[True,True] +[True] +[True] +[True] +[True] +[True,True] +[True] +[True] +[True] +[True,True,True,True,True,True,True] +[True,True,True,True,True,True] diff --git a/testsuite/tests/parser/should_run/all.T b/testsuite/tests/parser/should_run/all.T index 31dea7f5b7..0c9e65fd14 100644 --- a/testsuite/tests/parser/should_run/all.T +++ b/testsuite/tests/parser/should_run/all.T @@ -11,3 +11,6 @@ test('BinaryLiterals1', [], compile_and_run, ['']) test('BinaryLiterals2', [], compile_and_run, ['']) test('T10807', normal, compile_and_run, ['']) test('NegativeZero', normal, compile_and_run, ['']) +test('HexFloatLiterals', normal, compile_and_run, ['']) +test('NumericUnderscores0', normal, compile_and_run, ['']) +test('NumericUnderscores1', normal, compile_and_run, ['']) |