diff options
author | Alfredo Di Napoli <alfredo@well-typed.com> | 2021-07-13 08:32:12 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-07-19 19:37:47 -0400 |
commit | 3e8b39eaf098769d33c9a46657c18a277397424c (patch) | |
tree | b4bd86688e692f194d29ec29396cc8c44fc5d71d | |
parent | 952ba18e596f406d08003a9ff07f95a5a94a2ede (diff) | |
download | haskell-3e8b39eaf098769d33c9a46657c18a277397424c.tar.gz |
Rename RecordPuns to NamedFieldPuns in LangExt.Extension
This commit renames the `RecordPuns` type constructor inside
`GHC.LanguageExtensions.Type.hs` to `NamedFieldPuns`.
The rationale is that the `RecordPuns` language extension was deprecated
a long time ago, but it was still present in the AST, introducing an
annoying mismatch between what GHC suggested (i.e. "use NamedFieldPuns")
and what that translated into in terms of Haskell types.
-rw-r--r-- | compiler/GHC/Driver/Session.hs | 6 | ||||
-rw-r--r-- | compiler/GHC/Rename/Expr.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Rename/Pat.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Rename/Utils.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Tc/Errors/Ppr.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Types/Hint/Ppr.hs | 4 | ||||
-rw-r--r-- | libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs | 2 |
7 files changed, 9 insertions, 13 deletions
diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs index 78add24b2b..b190fe70a9 100644 --- a/compiler/GHC/Driver/Session.hs +++ b/compiler/GHC/Driver/Session.hs @@ -1398,7 +1398,7 @@ languageExtensions (Just GHC2021) LangExt.InstanceSigs, LangExt.KindSignatures, LangExt.MultiParamTypeClasses, - LangExt.RecordPuns, + LangExt.NamedFieldPuns, LangExt.NamedWildCards, LangExt.NumericUnderscores, LangExt.PolyKinds, @@ -3594,7 +3594,7 @@ xFlagsDeps = [ flagSpec "MultiWayIf" LangExt.MultiWayIf, flagSpec "NumericUnderscores" LangExt.NumericUnderscores, flagSpec "NPlusKPatterns" LangExt.NPlusKPatterns, - flagSpec "NamedFieldPuns" LangExt.RecordPuns, + flagSpec "NamedFieldPuns" LangExt.NamedFieldPuns, flagSpec "NamedWildCards" LangExt.NamedWildCards, flagSpec "NegativeLiterals" LangExt.NegativeLiterals, flagSpec "HexFloatLiterals" LangExt.HexFloatLiterals, @@ -3627,7 +3627,7 @@ xFlagsDeps = [ flagSpec "RebindableSyntax" LangExt.RebindableSyntax, flagSpec "OverloadedRecordDot" LangExt.OverloadedRecordDot, flagSpec "OverloadedRecordUpdate" LangExt.OverloadedRecordUpdate, - depFlagSpec' "RecordPuns" LangExt.RecordPuns + depFlagSpec' "RecordPuns" LangExt.NamedFieldPuns (deprecatedForExtension "NamedFieldPuns"), flagSpec "RecordWildCards" LangExt.RecordWildCards, flagSpec "RecursiveDo" LangExt.RecursiveDo, diff --git a/compiler/GHC/Rename/Expr.hs b/compiler/GHC/Rename/Expr.hs index cd0707ef59..72e18ed388 100644 --- a/compiler/GHC/Rename/Expr.hs +++ b/compiler/GHC/Rename/Expr.hs @@ -448,7 +448,7 @@ rnExpr (RecordUpd { rupd_expr = expr, rupd_flds = rbinds }) addErr $ TcRnUnknownMessage $ mkPlainError noHints $ text "RebindableSyntax is required if OverloadedRecordUpdate is enabled." ; let punnedFields = [fld | (L _ fld) <- flds, hfbPun fld] - ; punsEnabled <-xoptM LangExt.RecordPuns + ; punsEnabled <-xoptM LangExt.NamedFieldPuns ; unless (null punnedFields || punsEnabled) $ addErr $ TcRnUnknownMessage $ mkPlainError noHints $ text "For this to work enable NamedFieldPuns." diff --git a/compiler/GHC/Rename/Pat.hs b/compiler/GHC/Rename/Pat.hs index 28e4c806a1..0a149f473e 100644 --- a/compiler/GHC/Rename/Pat.hs +++ b/compiler/GHC/Rename/Pat.hs @@ -754,7 +754,7 @@ rnHsRecFields -- This is used for record construction and pattern-matching, but not updates. rnHsRecFields ctxt mk_arg (HsRecFields { rec_flds = flds, rec_dotdot = dotdot }) - = do { pun_ok <- xoptM LangExt.RecordPuns + = do { pun_ok <- xoptM LangExt.NamedFieldPuns ; disambig_ok <- xoptM LangExt.DisambiguateRecordFields ; let parent = guard disambig_ok >> mb_con ; flds1 <- mapM (rn_fld pun_ok parent) flds @@ -863,7 +863,7 @@ rnHsRecUpdFields :: [LHsRecUpdField GhcPs] -> RnM ([LHsRecUpdField GhcRn], FreeVars) rnHsRecUpdFields flds - = do { pun_ok <- xoptM LangExt.RecordPuns + = do { pun_ok <- xoptM LangExt.NamedFieldPuns ; dup_fields_ok <- xopt_DuplicateRecordFields <$> getDynFlags ; (flds1, fvss) <- mapAndUnzipM (rn_fld pun_ok dup_fields_ok) flds ; mapM_ (addErr . dupFieldErr HsRecFieldUpd) dup_flds diff --git a/compiler/GHC/Rename/Utils.hs b/compiler/GHC/Rename/Utils.hs index ed1cf40ea4..37a229e203 100644 --- a/compiler/GHC/Rename/Utils.hs +++ b/compiler/GHC/Rename/Utils.hs @@ -180,7 +180,7 @@ checkShadowedOccs (global_env,local_env) get_loc_occ ns -- punning or wild-cards are on (cf #2723) is_shadowed_gre gre | isRecFldGRE gre = do { dflags <- getDynFlags - ; return $ not (xopt LangExt.RecordPuns dflags + ; return $ not (xopt LangExt.NamedFieldPuns dflags || xopt LangExt.RecordWildCards dflags) } is_shadowed_gre _other = return True diff --git a/compiler/GHC/Tc/Errors/Ppr.hs b/compiler/GHC/Tc/Errors/Ppr.hs index 0ef1d48ac5..97d0a40413 100644 --- a/compiler/GHC/Tc/Errors/Ppr.hs +++ b/compiler/GHC/Tc/Errors/Ppr.hs @@ -171,7 +171,7 @@ instance Diagnostic TcRnMessage where TcRnEmptyRecordUpdate{} -> noHints TcRnIllegalFieldPunning{} - -> [SuggestExtension LangExt.RecordPuns] + -> [SuggestExtension LangExt.NamedFieldPuns] TcRnIllegalWildcardsInRecord{} -> [SuggestExtension LangExt.RecordWildCards] TcRnDuplicateFieldName{} diff --git a/compiler/GHC/Types/Hint/Ppr.hs b/compiler/GHC/Types/Hint/Ppr.hs index 56d105dd53..24e0da427d 100644 --- a/compiler/GHC/Types/Hint/Ppr.hs +++ b/compiler/GHC/Types/Hint/Ppr.hs @@ -25,10 +25,6 @@ instance Outputable GhcHint where -> case ext of LangExt.NegativeLiterals -> text "If you are trying to write a large negative literal, use NegativeLiterals" - -- RecordPuns is now effectively 'NamedFieldPuns', so we have to pretty-print the - -- hint to yield the correct suggestion in terms of extension to enable. - LangExt.RecordPuns - -> text "Perhaps you intended to use NamedFieldPuns" _ -> text "Perhaps you intended to use" <+> ppr ext SuggestMissingDo -> text "Possibly caused by a missing 'do'?" diff --git a/libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs b/libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs index 8dc2b67a36..ce07116a1e 100644 --- a/libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs +++ b/libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs @@ -61,7 +61,7 @@ data Extension | NumDecimals | DisambiguateRecordFields | RecordWildCards - | RecordPuns + | NamedFieldPuns | ViewPatterns | GADTs | GADTSyntax |