diff options
| author | Simon Peyton Jones <simonpj@microsoft.com> | 2013-02-27 09:57:09 +0000 |
|---|---|---|
| committer | Simon Peyton Jones <simonpj@microsoft.com> | 2013-02-27 09:57:09 +0000 |
| commit | 47d226544fc3fb11d024740a162f8ae4e1d044c9 (patch) | |
| tree | 8a024b97de71216f6b3606d3cda7bf16ae1f98a6 /compiler/rename/RnExpr.lhs | |
| parent | 7b5e514d85c086be8dc6d938b526c97b6ced56eb (diff) | |
| parent | 0ee31659afe7a6819f9eb5e233f98e5592f1b439 (diff) | |
| download | haskell-tc-arrows.tar.gz | |
Merge remote-tracking branch 'origin/master' into tc-arrowstc-arrows
Diffstat (limited to 'compiler/rename/RnExpr.lhs')
| -rw-r--r-- | compiler/rename/RnExpr.lhs | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/compiler/rename/RnExpr.lhs b/compiler/rename/RnExpr.lhs index 8e4d554a46..29674ca34c 100644 --- a/compiler/rename/RnExpr.lhs +++ b/compiler/rename/RnExpr.lhs @@ -53,6 +53,7 @@ import Outputable import SrcLoc import FastString import Control.Monad +import TysWiredIn ( nilDataConName ) \end{code} @@ -108,14 +109,18 @@ finishHsVar name ; return (e, unitFV name) } } rnExpr (HsVar v) - = do { opt_TypeHoles <- xoptM Opt_TypeHoles - ; if opt_TypeHoles && startsWithUnderscore (rdrNameOcc v) - then do { mb_name <- lookupOccRn_maybe v - ; case mb_name of - Nothing -> return (HsUnboundVar v, emptyFVs) - Just n -> finishHsVar n } - else do { name <- lookupOccRn v - ; finishHsVar name } } + = do { mb_name <- lookupOccRn_maybe v + ; case mb_name of { + Nothing -> do { opt_TypeHoles <- xoptM Opt_TypeHoles + ; if opt_TypeHoles && startsWithUnderscore (rdrNameOcc v) + then return (HsUnboundVar v, emptyFVs) + else do { n <- reportUnboundName v; finishHsVar n } } ; + Just name + | name == nilDataConName -- Treat [] as an ExplicitList, so that + -- OverloadedLists works correctly + -> rnExpr (ExplicitList placeHolderType Nothing []) + | otherwise + -> finishHsVar name } } rnExpr (HsIPVar v) = return (HsIPVar v, emptyFVs) @@ -249,9 +254,15 @@ rnExpr (HsDo do_or_lc stmts _) = do { ((stmts', _), fvs) <- rnStmts do_or_lc rnLExpr stmts (\ _ -> return ((), emptyFVs)) ; return ( HsDo do_or_lc stmts' placeHolderType, fvs ) } -rnExpr (ExplicitList _ exps) - = rnExprs exps `thenM` \ (exps', fvs) -> - return (ExplicitList placeHolderType exps', fvs) +rnExpr (ExplicitList _ _ exps) + = do { opt_OverloadedLists <- xoptM Opt_OverloadedLists + ; (exps', fvs) <- rnExprs exps + ; if opt_OverloadedLists + then do { + ; (from_list_n_name, fvs') <- lookupSyntaxName fromListNName + ; return (ExplicitList placeHolderType (Just from_list_n_name) exps', fvs `plusFV` fvs') } + else + return (ExplicitList placeHolderType Nothing exps', fvs) } rnExpr (ExplicitPArr _ exps) = rnExprs exps `thenM` \ (exps', fvs) -> @@ -299,9 +310,15 @@ rnExpr (HsType a) = rnLHsType HsTypeCtx a `thenM` \ (t, fvT) -> return (HsType t, fvT) -rnExpr (ArithSeq _ seq) - = rnArithSeq seq `thenM` \ (new_seq, fvs) -> - return (ArithSeq noPostTcExpr new_seq, fvs) +rnExpr (ArithSeq _ _ seq) + = do { opt_OverloadedLists <- xoptM Opt_OverloadedLists + ; (new_seq, fvs) <- rnArithSeq seq + ; if opt_OverloadedLists + then do { + ; (from_list_name, fvs') <- lookupSyntaxName fromListName + ; return (ArithSeq noPostTcExpr (Just from_list_name) new_seq, fvs `plusFV` fvs') } + else + return (ArithSeq noPostTcExpr Nothing new_seq, fvs) } rnExpr (PArrSeq _ seq) = rnArithSeq seq `thenM` \ (new_seq, fvs) -> |
