Ticket #7266: NumDecimals-detab.patch

File NumDecimals-detab.patch, 27.0 KB (added by shachaf, 3 years ago)

detab RnPat.lhs

  • compiler/rename/RnPat.lhs

    diff --git a/compiler/rename/RnPat.lhs b/compiler/rename/RnPat.lhs
    index 405e4c7..82a6eb7 100644
    a b general, all of these functions return a renamed thing, and a set of 
    1010free variables. 
    1111 
    1212\begin{code} 
    13 {-# OPTIONS -fno-warn-tabs #-} 
    14 -- The above warning supression flag is a temporary kludge. 
    15 -- While working on this module you are encouraged to remove it and 
    16 -- detab the module (please do the detabbing in a separate patch). See 
    17 --     http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#TabsvsSpaces 
    18 -- for details 
    1913 
    2014{-# LANGUAGE ScopedTypeVariables #-} 
    2115module RnPat (-- main entry points 
    module RnPat (-- main entry points 
    2721 
    2822              rnHsRecFields1, HsRecFieldContext(..), 
    2923 
    30               -- Literals 
    31               rnLit, rnOverLit,      
     24              -- Literals 
     25              rnLit, rnOverLit, 
    3226 
    3327             -- Pattern Error messages that are also used elsewhere 
    3428             checkTupSize, patSigErr 
    module RnPat (-- main entry points 
    3933import {-# SOURCE #-} RnExpr ( rnLExpr ) 
    4034#ifdef GHCI 
    4135import {-# SOURCE #-} TcSplice ( runQuasiQuotePat ) 
    42 #endif  /* GHCI */ 
     36#endif /* GHCI */ 
    4337 
    4438#include "HsVersions.h" 
    4539 
    46 import HsSyn             
     40import HsSyn 
    4741import TcRnMonad 
    48 import TcHsSyn          ( hsOverLitName ) 
     42import TcHsSyn ( hsOverLitName ) 
    4943import RnEnv 
    5044import RnTypes 
    5145import DynFlags 
    import NameSet 
    5549import RdrName 
    5650import BasicTypes 
    5751import Util 
    58 import ListSetOps       ( removeDups ) 
     52import ListSetOps ( removeDups ) 
    5953import Outputable 
    6054import SrcLoc 
    6155import FastString 
    62 import Literal          ( inCharRange ) 
    63 import Control.Monad    ( when ) 
     56import Literal ( inCharRange ) 
     57import Control.Monad ( when ) 
    6458import Data.Ratio 
    6559\end{code} 
    6660 
    6761 
    6862%********************************************************* 
    69 %*                                                      * 
    70         The CpsRn Monad 
    71 %*                                                      * 
     63%*                                                      * 
     64        The CpsRn Monad 
     65%*                                                      * 
    7266%********************************************************* 
    7367 
    7468Note [CpsRn monad] 
    Note [CpsRn monad] 
    7670The CpsRn monad uses continuation-passing style to support this 
    7771style of programming: 
    7872 
    79         do { ... 
     73        do { ... 
    8074           ; ns <- bindNames rs 
    8175           ; ...blah... } 
    8276 
    8377   where rs::[RdrName], ns::[Name] 
    8478 
    85 The idea is that '...blah...'  
     79The idea is that '...blah...' 
    8680  a) sees the bindings of ns 
    8781  b) returns the free variables it mentions 
    8882     so that bindNames can report unused ones 
    8983 
    90 In particular,  
     84In particular, 
    9185    mapM rnPatAndThen [p1, p2, p3] 
    92 has a *left-to-right* scoping: it makes the binders in  
     86has a *left-to-right* scoping: it makes the binders in 
    9387p1 scope over p2,p3. 
    9488 
    9589\begin{code} 
    9690newtype CpsRn b = CpsRn { unCpsRn :: forall r. (b -> RnM (r, FreeVars)) 
    9791                                            -> RnM (r, FreeVars) } 
    98         -- See Note [CpsRn monad] 
     92        -- See Note [CpsRn monad] 
    9993 
    10094instance Monad CpsRn where 
    10195  return x = CpsRn (\k -> k x) 
    liftCpsFV rn_thing = CpsRn (\k -> do { (v,fvs1) <- rn_thing 
    115109wrapSrcSpanCps :: (a -> CpsRn b) -> Located a -> CpsRn (Located b) 
    116110-- Set the location, and also wrap it around the value returned 
    117111wrapSrcSpanCps fn (L loc a) 
    118   = CpsRn (\k -> setSrcSpan loc $  
    119                  unCpsRn (fn a) $ \v ->  
     112  = CpsRn (\k -> setSrcSpan loc $ 
     113                 unCpsRn (fn a) $ \v -> 
    120114                 k (L loc v)) 
    121115 
    122116lookupConCps :: Located RdrName -> CpsRn (Located Name) 
    123 lookupConCps con_rdr  
     117lookupConCps con_rdr 
    124118  = CpsRn (\k -> do { con_name <- lookupLocatedOccRn con_rdr 
    125119                    ; (r, fvs) <- k con_name 
    126120                    ; return (r, fvs `plusFV` unitFV (unLoc con_name)) }) 
    127121\end{code} 
    128122 
    129123%********************************************************* 
    130 %*                                                      * 
    131         Name makers 
    132 %*                                                      * 
     124%*                                                      * 
     125        Name makers 
     126%*                                                      * 
    133127%********************************************************* 
    134128 
    135129Externally abstract type of name makers, 
    136130which is how you go from a RdrName to a Name 
    137131 
    138132\begin{code} 
    139 data NameMaker  
    140   = LamMk       -- Lambdas  
    141       Bool      -- True <=> report unused bindings 
    142                 --   (even if True, the warning only comes out  
    143                 --    if -fwarn-unused-matches is on) 
     133data NameMaker 
     134  = LamMk       -- Lambdas 
     135      Bool      -- True <=> report unused bindings 
     136                --   (even if True, the warning only comes out 
     137                --    if -fwarn-unused-matches is on) 
    144138 
    145139  | LetMk       -- Let bindings, incl top level 
    146                 -- Do *not* check for unused bindings 
     140                -- Do *not* check for unused bindings 
    147141      TopLevelFlag 
    148142      MiniFixityEnv 
    149143 
    topRecNameMaker :: MiniFixityEnv -> NameMaker 
    151145topRecNameMaker fix_env = LetMk TopLevel fix_env 
    152146 
    153147localRecNameMaker :: MiniFixityEnv -> NameMaker 
    154 localRecNameMaker fix_env = LetMk NotTopLevel fix_env  
     148localRecNameMaker fix_env = LetMk NotTopLevel fix_env 
    155149 
    156150matchNameMaker :: HsMatchContext a -> NameMaker 
    157151matchNameMaker ctxt = LamMk report_unused 
    matchNameMaker ctxt = LamMk report_unused 
    163157                      _                 -> True 
    164158 
    165159rnHsSigCps :: HsWithBndrs (LHsType RdrName) -> CpsRn (HsWithBndrs (LHsType Name)) 
    166 rnHsSigCps sig  
     160rnHsSigCps sig 
    167161  = CpsRn (rnHsBndrSig PatCtx sig) 
    168162 
    169163newPatName :: NameMaker -> Located RdrName -> CpsRn Name 
    170164newPatName (LamMk report_unused) rdr_name 
    171   = CpsRn (\ thing_inside ->  
    172         do { name <- newLocalBndrRn rdr_name 
    173            ; (res, fvs) <- bindLocalName name (thing_inside name) 
    174            ; when report_unused $ warnUnusedMatches [name] fvs 
    175            ; return (res, name `delFV` fvs) }) 
     165  = CpsRn (\ thing_inside -> 
     166        do { name <- newLocalBndrRn rdr_name 
     167           ; (res, fvs) <- bindLocalName name (thing_inside name) 
     168           ; when report_unused $ warnUnusedMatches [name] fvs 
     169           ; return (res, name `delFV` fvs) }) 
    176170 
    177171newPatName (LetMk is_top fix_env) rdr_name 
    178   = CpsRn (\ thing_inside ->  
     172  = CpsRn (\ thing_inside -> 
    179173        do { name <- case is_top of 
    180174                       NotTopLevel -> newLocalBndrRn rdr_name 
    181175                       TopLevel    -> newTopSrcBinder rdr_name 
    182            ; bindLocalName name $       -- Do *not* use bindLocalNameFV here 
    183                                         -- See Note [View pattern usage] 
     176           ; bindLocalName name $       -- Do *not* use bindLocalNameFV here 
     177                                        -- See Note [View pattern usage] 
    184178             addLocalFixities fix_env [name] $ 
    185              thing_inside name }) 
    186                            
     179             thing_inside name }) 
     180 
    187181    -- Note: the bindLocalName is somewhat suspicious 
    188182    --       because it binds a top-level name as a local name. 
    189183    --       however, this binding seems to work, and it only exists for 
    report unused variables at the binding level. So we must use bindLocalName 
    202196here, *not* bindLocalNameFV.  Trac #3943. 
    203197 
    204198%********************************************************* 
    205 %*                                                      * 
    206         External entry points 
    207 %*                                                      * 
     199%*                                                      * 
     200        External entry points 
     201%*                                                      * 
    208202%********************************************************* 
    209203 
    210204There are various entry points to renaming patterns, depending on 
    There are various entry points to renaming patterns, depending on 
    212206 (2) whether the scope of the names is entirely given in a continuation 
    213207     (e.g., in a case or lambda, but not in a let or at the top-level, 
    214208      because of the way mutually recursive bindings are handled) 
    215  (3) whether the a type signature in the pattern can bind  
    216         lexically-scoped type variables (for unpacking existential  
    217         type vars in data constructors) 
     209 (3) whether the a type signature in the pattern can bind 
     210        lexically-scoped type variables (for unpacking existential 
     211        type vars in data constructors) 
    218212 (4) whether we do duplicate and unused variable checking 
    219213 (5) whether there are fixity declarations associated with the names 
    220214     bound by the patterns that need to be brought into scope with them. 
    221       
     215 
    222216 Rather than burdening the clients of this module with all of these choices, 
    223217 we export the three points in this design space that we actually need: 
    224218 
    There are various entry points to renaming patterns, depending on 
    230224--   * unused and duplicate checking 
    231225--   * no fixities 
    232226rnPats :: HsMatchContext Name -- for error messages 
    233        -> [LPat RdrName]  
     227       -> [LPat RdrName] 
    234228       -> ([LPat Name] -> RnM (a, FreeVars)) 
    235229       -> RnM (a, FreeVars) 
    236230rnPats ctxt pats thing_inside 
    237   = do  { envs_before <- getRdrEnvs 
    238  
    239           -- (1) rename the patterns, bringing into scope all of the term variables 
    240           -- (2) then do the thing inside. 
    241         ; unCpsRn (rnLPatsAndThen (matchNameMaker ctxt) pats) $ \ pats' -> do 
    242         { -- Check for duplicated and shadowed names  
    243           -- Must do this *after* renaming the patterns 
    244           -- See Note [Collect binders only after renaming] in HsUtils 
     231  = do  { envs_before <- getRdrEnvs 
     232 
     233          -- (1) rename the patterns, bringing into scope all of the term variables 
     234          -- (2) then do the thing inside. 
     235        ; unCpsRn (rnLPatsAndThen (matchNameMaker ctxt) pats) $ \ pats' -> do 
     236        { -- Check for duplicated and shadowed names 
     237          -- Must do this *after* renaming the patterns 
     238          -- See Note [Collect binders only after renaming] in HsUtils 
    245239          -- Because we don't bind the vars all at once, we can't 
    246           --    check incrementally for duplicates;  
    247           -- Nor can we check incrementally for shadowing, else we'll 
    248           --    complain *twice* about duplicates e.g. f (x,x) = ... 
    249         ; addErrCtxt doc_pat $  
     240          --    check incrementally for duplicates; 
     241          -- Nor can we check incrementally for shadowing, else we'll 
     242          --    complain *twice* about duplicates e.g. f (x,x) = ... 
     243        ; addErrCtxt doc_pat $ 
    250244          checkDupAndShadowedNames envs_before $ 
    251245          collectPatsBinders pats' 
    252246        ; thing_inside pats' } } 
    rnPats ctxt pats thing_inside 
    254248    doc_pat = ptext (sLit "In") <+> pprMatchContext ctxt 
    255249 
    256250rnPat :: HsMatchContext Name -- for error messages 
    257       -> LPat RdrName  
     251      -> LPat RdrName 
    258252      -> (LPat Name -> RnM (a, FreeVars)) 
    259       -> RnM (a, FreeVars)     -- Variables bound by pattern do not  
    260                                -- appear in the result FreeVars  
    261 rnPat ctxt pat thing_inside  
     253      -> RnM (a, FreeVars)     -- Variables bound by pattern do not 
     254                               -- appear in the result FreeVars 
     255rnPat ctxt pat thing_inside 
    262256  = rnPats ctxt [pat] (\pats' -> let [pat'] = pats' in thing_inside pat') 
    263257 
    264258applyNameMaker :: NameMaker -> Located RdrName -> RnM Name 
    applyNameMaker mk rdr = do { (n, _fvs) <- runCps (newPatName mk rdr); return n } 
    266260 
    267261-- ----------- Entry point 2: rnBindPat ------------------- 
    268262-- Binds local names; in a recursive scope that involves other bound vars 
    269 --      e.g let { (x, Just y) = e1; ... } in ... 
     263--      e.g let { (x, Just y) = e1; ... } in ... 
    270264--   * does NOT allows type sig to bind type vars 
    271265--   * local namemaker 
    272266--   * no unused and duplicate checking 
    rnBindPat :: NameMaker 
    275269          -> LPat RdrName 
    276270          -> RnM (LPat Name, FreeVars) 
    277271   -- Returned FreeVars are the free variables of the pattern, 
    278    -- of course excluding variables bound by this pattern  
     272   -- of course excluding variables bound by this pattern 
    279273 
    280274rnBindPat name_maker pat = runCps (rnLPatAndThen name_maker pat) 
    281275\end{code} 
    282276 
    283277 
    284278%********************************************************* 
    285 %*                                                      * 
    286         The main event 
    287 %*                                                      * 
     279%*                                                      * 
     280        The main event 
     281%*                                                      * 
    288282%********************************************************* 
    289283 
    290284\begin{code} 
    rnPatAndThen mk (VarPat rdr) = do { loc <- liftCps getSrcSpanM 
    311305                                   ; return (VarPat name) } 
    312306     -- we need to bind pattern variables for view pattern expressions 
    313307     -- (e.g. in the pattern (x, x -> y) x needs to be bound in the rhs of the tuple) 
    314                                       
     308 
    315309rnPatAndThen mk (SigPatIn pat sig) 
    316310  = do { pat' <- rnLPatAndThen mk pat 
    317311       ; sig' <- rnHsSigCps sig 
    318312       ; return (SigPatIn pat' sig') } 
    319         
     313 
    320314rnPatAndThen mk (LitPat lit) 
    321315  | HsString s <- lit 
    322316  = do { ovlStr <- liftCps (xoptM Opt_OverloadedStrings) 
    323        ; if ovlStr  
     317       ; if ovlStr 
    324318         then rnPatAndThen mk (mkNPat (mkHsIsString s placeHolderType) Nothing) 
    325319         else normal_lit } 
    326320  | otherwise = normal_lit 
    rnPatAndThen mk (LitPat lit) 
    330324rnPatAndThen _ (NPat lit mb_neg _eq) 
    331325  = do { lit'    <- liftCpsFV $ rnOverLit lit 
    332326       ; mb_neg' <- liftCpsFV $ case mb_neg of 
    333                       Nothing -> return (Nothing, emptyFVs) 
    334                       Just _  -> do { (neg, fvs) <- lookupSyntaxName negateName 
    335                                     ; return (Just neg, fvs) } 
     327                      Nothing -> return (Nothing, emptyFVs) 
     328                      Just _  -> do { (neg, fvs) <- lookupSyntaxName negateName 
     329                                    ; return (Just neg, fvs) } 
    336330       ; eq' <- liftCpsFV $ lookupSyntaxName eqName 
    337331       ; return (NPat lit' mb_neg' eq') } 
    338332 
    rnPatAndThen mk (NPlusKPat rdr lit _ _) 
    342336       ; minus <- liftCpsFV $ lookupSyntaxName minusName 
    343337       ; ge    <- liftCpsFV $ lookupSyntaxName geName 
    344338       ; return (NPlusKPat (L (nameSrcSpan new_name) new_name) lit' ge minus) } 
    345                 -- The Report says that n+k patterns must be in Integral 
     339                -- The Report says that n+k patterns must be in Integral 
    346340 
    347341rnPatAndThen mk (AsPat rdr pat) 
    348342  = do { new_name <- newPatName mk rdr 
    rnPatAndThen mk p@(ViewPat expr pat ty) 
    353347  = do { liftCps $ do { vp_flag <- xoptM Opt_ViewPatterns 
    354348                      ; checkErr vp_flag (badViewPat p) } 
    355349         -- Because of the way we're arranging the recursive calls, 
    356          -- this will be in the right context  
    357        ; expr' <- liftCpsFV $ rnLExpr expr  
     350         -- this will be in the right context 
     351       ; expr' <- liftCpsFV $ rnLExpr expr 
    358352       ; pat' <- rnLPatAndThen mk pat 
    359353       ; return (ViewPat expr' pat' ty) } 
    360354 
    rnPatAndThen mk (TuplePat pats boxed _) 
    376370       ; return (TuplePat pats' boxed placeHolderType) } 
    377371 
    378372#ifndef GHCI 
    379 rnPatAndThen _ p@(QuasiQuotePat {})  
     373rnPatAndThen _ p@(QuasiQuotePat {}) 
    380374  = pprPanic "Can't do QuasiQuotePat without GHCi" (ppr p) 
    381375#else 
    382376rnPatAndThen mk (QuasiQuotePat qq) 
    383377  = do { pat <- liftCps $ runQuasiQuotePat qq 
    384378       ; L _ pat' <- rnLPatAndThen mk pat 
    385379       ; return pat' } 
    386 #endif  /* GHCI */ 
     380#endif  /* GHCI */ 
    387381 
    388382rnPatAndThen _ pat = pprPanic "rnLPatAndThen" (ppr pat) 
    389383 
    rnPatAndThen _ pat = pprPanic "rnLPatAndThen" (ppr pat) 
    391385-------------------- 
    392386rnConPatAndThen :: NameMaker 
    393387                -> Located RdrName          -- the constructor 
    394                 -> HsConPatDetails RdrName  
     388                -> HsConPatDetails RdrName 
    395389                -> CpsRn (Pat Name) 
    396390 
    397391rnConPatAndThen mk con (PrefixCon pats) 
    398   = do  { con' <- lookupConCps con 
    399         ; pats' <- rnLPatsAndThen mk pats 
    400         ; return (ConPatIn con' (PrefixCon pats')) } 
     392  = do  { con' <- lookupConCps con 
     393        ; pats' <- rnLPatsAndThen mk pats 
     394        ; return (ConPatIn con' (PrefixCon pats')) } 
    401395 
    402396rnConPatAndThen mk con (InfixCon pat1 pat2) 
    403   = do  { con' <- lookupConCps con 
    404         ; pat1' <- rnLPatAndThen mk pat1 
    405         ; pat2' <- rnLPatAndThen mk pat2 
    406         ; fixity <- liftCps $ lookupFixityRn (unLoc con') 
    407         ; liftCps $ mkConOpPatRn con' fixity pat1' pat2' } 
     397  = do  { con' <- lookupConCps con 
     398        ; pat1' <- rnLPatAndThen mk pat1 
     399        ; pat2' <- rnLPatAndThen mk pat2 
     400        ; fixity <- liftCps $ lookupFixityRn (unLoc con') 
     401        ; liftCps $ mkConOpPatRn con' fixity pat1' pat2' } 
    408402 
    409403rnConPatAndThen mk con (RecCon rpats) 
    410   = do  { con' <- lookupConCps con 
    411         ; rpats' <- rnHsRecPatsAndThen mk con' rpats 
    412         ; return (ConPatIn con' (RecCon rpats')) } 
     404  = do  { con' <- lookupConCps con 
     405        ; rpats' <- rnHsRecPatsAndThen mk con' rpats 
     406        ; return (ConPatIn con' (RecCon rpats')) } 
    413407 
    414408-------------------- 
    415409rnHsRecPatsAndThen :: NameMaker 
    416                    -> Located Name      -- Constructor 
    417                    -> HsRecFields RdrName (LPat RdrName) 
    418                    -> CpsRn (HsRecFields Name (LPat Name)) 
     410                   -> Located Name      -- Constructor 
     411                   -> HsRecFields RdrName (LPat RdrName) 
     412                   -> CpsRn (HsRecFields Name (LPat Name)) 
    419413rnHsRecPatsAndThen mk (L _ con) hs_rec_fields@(HsRecFields { rec_dotdot = dd }) 
    420414  = do { flds <- liftCpsFV $ rnHsRecFields1 (HsRecFieldPat con) VarPat hs_rec_fields 
    421415       ; flds' <- mapM rn_field (flds `zip` [1..]) 
    422416       ; return (HsRecFields { rec_flds = flds', rec_dotdot = dd }) } 
    423   where  
    424     rn_field (fld, n') = do { arg' <- rnLPatAndThen (nested_mk dd mk n')  
     417  where 
     418    rn_field (fld, n') = do { arg' <- rnLPatAndThen (nested_mk dd mk n') 
    425419                                                    (hsRecFieldArg fld) 
    426420                            ; return (fld { hsRecFieldArg = arg' }) } 
    427421 
    428         -- Suppress unused-match reporting for fields introduced by ".." 
     422        -- Suppress unused-match reporting for fields introduced by ".." 
    429423    nested_mk Nothing  mk                    _  = mk 
    430424    nested_mk (Just _) mk@(LetMk {})         _  = mk 
    431425    nested_mk (Just n) (LamMk report_unused) n' = LamMk (report_unused && (n' <= n)) 
    rnHsRecPatsAndThen mk (L _ con) hs_rec_fields@(HsRecFields { rec_dotdot = dd }) 
    433427 
    434428 
    435429%************************************************************************ 
    436 %*                                                                      * 
    437         Record fields 
    438 %*                                                                      * 
     430%*                                                                      * 
     431        Record fields 
     432%*                                                                      * 
    439433%************************************************************************ 
    440434 
    441435\begin{code} 
    442 data HsRecFieldContext  
     436data HsRecFieldContext 
    443437  = HsRecFieldCon Name 
    444438  | HsRecFieldPat Name 
    445439  | HsRecFieldUpd 
    446440 
    447 rnHsRecFields1  
    448     :: forall arg.  
     441rnHsRecFields1 
     442    :: forall arg. 
    449443       HsRecFieldContext 
    450444    -> (RdrName -> arg) -- When punning, use this to build a new field 
    451445    -> HsRecFields RdrName (Located arg) 
    rnHsRecFields1 ctxt mk_arg (HsRecFields { rec_flds = flds, rec_dotdot = dotdot } 
    469463       ; return (all_flds, mkFVs (getFieldIds all_flds)) } 
    470464  where 
    471465    mb_con = case ctxt of 
    472                 HsRecFieldCon con | not (isUnboundName con) -> Just con 
    473                 HsRecFieldPat con | not (isUnboundName con) -> Just con 
    474                 _other -> Nothing 
    475            -- The unbound name test is because if the constructor  
    476            -- isn't in scope the constructor lookup will add an error 
    477            -- add an error, but still return an unbound name.  
    478            -- We don't want that to screw up the dot-dot fill-in stuff. 
     466                HsRecFieldCon con | not (isUnboundName con) -> Just con 
     467                HsRecFieldPat con | not (isUnboundName con) -> Just con 
     468                _other -> Nothing 
     469           -- The unbound name test is because if the constructor 
     470           -- isn't in scope the constructor lookup will add an error 
     471           -- add an error, but still return an unbound name. 
     472           -- We don't want that to screw up the dot-dot fill-in stuff. 
    479473 
    480474    doc = case mb_con of 
    481475            Nothing  -> ptext (sLit "constructor field name") 
    482476            Just con -> ptext (sLit "field of constructor") <+> quotes (ppr con) 
    483477 
    484478    rn_fld pun_ok parent (HsRecField { hsRecFieldId = fld 
    485                                      , hsRecFieldArg = arg 
    486                                      , hsRecPun = pun }) 
     479                                     , hsRecFieldArg = arg 
     480                                     , hsRecPun = pun }) 
    487481      = do { fld'@(L loc fld_nm) <- wrapLocM (lookupSubBndrOcc parent doc) fld 
    488            ; arg' <- if pun  
     482           ; arg' <- if pun 
    489483                     then do { checkErr pun_ok (badPun fld) 
    490484                             ; return (L loc (mk_arg (mkRdrUnqual (nameOccName fld_nm)))) } 
    491485                     else return arg 
    rnHsRecFields1 ctxt mk_arg (HsRecFields { rec_flds = flds, rec_dotdot = dotdot } 
    493487                                , hsRecFieldArg = arg' 
    494488                                , hsRecPun = pun }) } 
    495489 
    496     rn_dotdot :: Maybe Int      -- See Note [DotDot fields] in HsPat 
    497               -> Maybe Name     -- The constructor (Nothing for an update 
    498                                 --    or out of scope constructor) 
    499               -> [HsRecField Name (Located arg)]   -- Explicit fields 
    500               -> RnM [HsRecField Name (Located arg)]   -- Filled in .. fields 
     490    rn_dotdot :: Maybe Int      -- See Note [DotDot fields] in HsPat 
     491              -> Maybe Name     -- The constructor (Nothing for an update 
     492                                --    or out of scope constructor) 
     493              -> [HsRecField Name (Located arg)]   -- Explicit fields 
     494              -> RnM [HsRecField Name (Located arg)]   -- Filled in .. fields 
    501495    rn_dotdot Nothing _mb_con _flds     -- No ".." at all 
    502496      = return [] 
    503497    rn_dotdot (Just {}) Nothing _flds   -- ".." on record update 
    504498      = do { addErr (badDotDot ctxt); return [] } 
    505499    rn_dotdot (Just n) (Just con) flds -- ".." on record construction / pat match 
    506500      = ASSERT( n == length flds ) 
    507         do { loc <- getSrcSpanM -- Rather approximate 
     501        do { loc <- getSrcSpanM -- Rather approximate 
    508502           ; dd_flag <- xoptM Opt_RecordWildCards 
    509503           ; checkErr dd_flag (needFlagDotDot ctxt) 
    510            ; (rdr_env, lcl_env) <- getRdrEnvs 
     504           ; (rdr_env, lcl_env) <- getRdrEnvs 
    511505           ; con_fields <- lookupConstructorFields con 
    512506           ; let present_flds = getFieldIds flds 
    513507                 parent_tc = find_tycon rdr_env con 
    514508 
    515509                   -- For constructor uses (but not patterns) 
    516510                   -- the arg should be in scope (unqualified) 
    517                    -- ignoring the record field itself 
    518                    -- Eg.  data R = R { x,y :: Int } 
     511                   -- ignoring the record field itself 
     512                   -- Eg.  data R = R { x,y :: Int } 
    519513                   --      f x = R { .. }   -- Should expand to R {x=x}, not R{x=x,y=y} 
    520                  arg_in_scope fld  
     514                 arg_in_scope fld 
    521515                   = rdr `elemLocalRdrEnv` lcl_env 
    522516                   || notNull [ gre | gre <- lookupGRE_RdrName rdr rdr_env 
    523517                                    , case gre_par gre of 
    rnHsRecFields1 ctxt mk_arg (HsRecFields { rec_flds = flds, rec_dotdot = dotdot } 
    533527                                , not (null gres)  -- Check field is in scope 
    534528                                , case ctxt of 
    535529                                    HsRecFieldCon {} -> arg_in_scope fld 
    536                                     _other           -> True ]  
     530                                    _other           -> True ] 
    537531 
    538532           ; addUsedRdrNames (map greRdrName dot_dot_gres) 
    539533           ; return [ HsRecField 
    rnHsRecFields1 ctxt mk_arg (HsRecFields { rec_flds = flds, rec_dotdot = dotdot } 
    541535                        , hsRecFieldArg = L loc (mk_arg arg_rdr) 
    542536                        , hsRecPun      = False } 
    543537                    | gre <- dot_dot_gres 
    544                     , let fld     = gre_name gre 
    545                           arg_rdr = mkRdrUnqual (nameOccName fld) ] } 
     538                    , let fld     = gre_name gre 
     539                          arg_rdr = mkRdrUnqual (nameOccName fld) ] } 
    546540 
    547541    check_disambiguation :: Bool -> Maybe Name -> RnM Parent 
    548     -- When disambiguation is on,  
     542    -- When disambiguation is on, 
    549543    check_disambiguation disambig_ok mb_con 
    550544      | disambig_ok, Just con <- mb_con 
    551545      = do { env <- getGlobalRdrEnv; return (ParentIs (find_tycon env con)) } 
    552546      | otherwise = return NoParent 
    553   
     547 
    554548    find_tycon :: GlobalRdrEnv -> Name {- DataCon -} -> Name {- TyCon -} 
    555549    -- Return the parent *type constructor* of the data constructor 
    556     -- That is, the parent of the data constructor.   
     550    -- That is, the parent of the data constructor. 
    557551    -- That's the parent to use for looking up record fields. 
    558     find_tycon env con  
     552    find_tycon env con 
    559553      = case lookupGRE_Name env con of 
    560           [GRE { gre_par = ParentIs p }] -> p 
     554          [GRE { gre_par = ParentIs p }] -> p 
    561555          gres  -> pprPanic "find_tycon" (ppr con $$ ppr gres) 
    562556 
    563557    dup_flds :: [[RdrName]] 
    getFieldIds flds = map (unLoc . hsRecFieldId) flds 
    571565 
    572566needFlagDotDot :: HsRecFieldContext -> SDoc 
    573567needFlagDotDot ctxt = vcat [ptext (sLit "Illegal `..' in record") <+> pprRFC ctxt, 
    574                             ptext (sLit "Use -XRecordWildCards to permit this")] 
     568                            ptext (sLit "Use -XRecordWildCards to permit this")] 
    575569 
    576570badDotDot :: HsRecFieldContext -> SDoc 
    577571badDotDot ctxt = ptext (sLit "You cannot use `..' in a record") <+> pprRFC ctxt 
    578572 
    579573badPun :: Located RdrName -> SDoc 
    580574badPun fld = vcat [ptext (sLit "Illegal use of punning for field") <+> quotes (ppr fld), 
    581                    ptext (sLit "Use -XNamedFieldPuns to permit this")] 
     575                   ptext (sLit "Use -XNamedFieldPuns to permit this")] 
    582576 
    583577dupFieldErr :: HsRecFieldContext -> [RdrName] -> SDoc 
    584578dupFieldErr ctxt dups 
    585   = hsep [ptext (sLit "duplicate field name"),  
     579  = hsep [ptext (sLit "duplicate field name"), 
    586580          quotes (ppr (head dups)), 
    587           ptext (sLit "in record"), pprRFC ctxt] 
     581          ptext (sLit "in record"), pprRFC ctxt] 
    588582 
    589583pprRFC :: HsRecFieldContext -> SDoc 
    590584pprRFC (HsRecFieldCon {}) = ptext (sLit "construction") 
    pprRFC (HsRecFieldUpd {}) = ptext (sLit "update") 
    594588 
    595589 
    596590%************************************************************************ 
    597 %*                                                                      * 
     591%*                                                                      * 
    598592\subsubsection{Literals} 
    599 %*                                                                      * 
     593%*                                                                      * 
    600594%************************************************************************ 
    601595 
    602596When literals occur we have to make sure 
    rnOverLit origLit 
    623617            | otherwise       = origLit 
    624618          } 
    625619        ; let std_name = hsOverLitName val 
    626         ; (from_thing_name, fvs) <- lookupSyntaxName std_name 
    627         ; let rebindable = case from_thing_name of 
    628                                 HsVar v -> v /= std_name 
    629                                 _       -> panic "rnOverLit" 
    630         ; return (lit { ol_witness = from_thing_name 
    631                       , ol_rebindable = rebindable }, fvs) } 
     620        ; (from_thing_name, fvs) <- lookupSyntaxName std_name 
     621        ; let rebindable = case from_thing_name of 
     622                                HsVar v -> v /= std_name 
     623                                _       -> panic "rnOverLit" 
     624        ; return (lit { ol_witness = from_thing_name 
     625                      , ol_rebindable = rebindable }, fvs) } 
    632626\end{code} 
    633627 
    634628%************************************************************************ 
    635 %*                                                                      * 
     629%*                                                                      * 
    636630\subsubsection{Errors} 
    637 %*                                                                      * 
     631%*                                                                      * 
    638632%************************************************************************ 
    639633 
    640634\begin{code} 
    641635patSigErr :: Outputable a => a -> SDoc 
    642636patSigErr ty 
    643637  =  (ptext (sLit "Illegal signature in pattern:") <+> ppr ty) 
    644         $$ nest 4 (ptext (sLit "Use -XScopedTypeVariables to permit it")) 
     638        $$ nest 4 (ptext (sLit "Use -XScopedTypeVariables to permit it")) 
    645639 
    646640bogusCharError :: Char -> SDoc 
    647641bogusCharError c