One list in ConPat (part of #25127)
This patch changes PrefixCon to use one list instead of two: -data HsConDetails tyarg arg rec - = PrefixCon [tyarg] [arg] +data HsConDetails arg rec + = PrefixCon [arg] | RecCon rec | InfixCon arg arg The [tyarg] list is now gone. To understand the effect of this change, recall that there are three instantiations of HsConDetails: 1. type HsConPatDetails p = HsConDetails (HsConPatTyArg (NoGhcTc p)) -- tyarg (LPat p) -- arg (HsRecFields p (LPat p)) -- rec 2. type HsConDeclH98Details pass = HsConDetails Void -- tyarg (HsScaled pass (LBangType pass)) -- arg (XRec pass [LConDeclField pass]) -- rec 3. type HsPatSynDetails pass = HsConDetails Void -- tyarg (LIdP pass) -- arg [RecordPatSynField pass] -- rec In cases (2) and (3), tyarg was instantiated to Void, so the [tyarg] list was always empty. Its removal is basically a no-op. The interesting case is (1), which is used in ConPat to represent pattern matching of the form (MkE @tp1 @tp2 p1 p2). With this patch, its representation is changed as follows: ConPat "MkE" [tp1, tp2] [p1, p2] -- old ConPat "MkE" [InvisP tp1, InvisP tp2, p1, p2] -- new The new mixed-list representation is consintent with lambdas, where InvisP is already used to deal with \ @tp1 @tp2 p1 p2 -> body. The immediate effect of the new representation is an improvement to error messages. Consider the pattern (Con x @t y). Previously it resulted in a parse error because @t could not occur after x. Now it is reported as [GHC-14964]. Test case: TyAppPat_MisplacedApplication. In the long term, this is intended as preparation for #18389 and #25127, which would make (Con x @t y) potentially valid, e.g. if its type is Con :: forall a -> forall b. (a, b) -> T The TH AST is left unchanged for the moment to avoid breakage.
Showing
- compiler/GHC/Hs/Binds.hs 1 addition, 1 deletioncompiler/GHC/Hs/Binds.hs
- compiler/GHC/Hs/Decls.hs 1 addition, 1 deletioncompiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Instances.hs 0 additions, 4 deletionscompiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Pat.hs 7 additions, 16 deletionscompiler/GHC/Hs/Pat.hs
- compiler/GHC/Hs/Type.hs 6 additions, 6 deletionscompiler/GHC/Hs/Type.hs
- compiler/GHC/Hs/Utils.hs 6 additions, 10 deletionscompiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Docs.hs 1 addition, 1 deletioncompiler/GHC/HsToCore/Docs.hs
- compiler/GHC/HsToCore/Match.hs 3 additions, 3 deletionscompiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Match/Constructor.hs 2 additions, 2 deletionscompiler/GHC/HsToCore/Match/Constructor.hs
- compiler/GHC/HsToCore/Pmc/Desugar.hs 1 addition, 1 deletioncompiler/GHC/HsToCore/Pmc/Desugar.hs
- compiler/GHC/HsToCore/Quote.hs 6 additions, 8 deletionscompiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Iface/Ext/Ast.hs 11 additions, 25 deletionscompiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Parser.y 1 addition, 1 deletioncompiler/GHC/Parser.y
- compiler/GHC/Parser/Errors/Ppr.hs 0 additions, 6 deletionscompiler/GHC/Parser/Errors/Ppr.hs
- compiler/GHC/Parser/Errors/Types.hs 0 additions, 2 deletionscompiler/GHC/Parser/Errors/Types.hs
- compiler/GHC/Parser/PostProcess.hs 22 additions, 15 deletionscompiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Parser/PostProcess/Haddock.hs 2 additions, 2 deletionscompiler/GHC/Parser/PostProcess/Haddock.hs
- compiler/GHC/Rename/Bind.hs 2 additions, 2 deletionscompiler/GHC/Rename/Bind.hs
- compiler/GHC/Rename/Module.hs 10 additions, 10 deletionscompiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Pat.hs 7 additions, 11 deletionscompiler/GHC/Rename/Pat.hs
Loading
Please register or sign in to comment