summaryrefslogtreecommitdiff
path: root/compiler/rename/RnExpr.lhs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rename/RnExpr.lhs')
-rw-r--r--compiler/rename/RnExpr.lhs45
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) ->