diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2014-11-06 13:59:42 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2014-11-06 14:01:20 +0000 |
commit | 0f930ba2039e28d0083780a58adb37ff01a92019 (patch) | |
tree | 024c2446d5e20e2069c9ac97a2f14d49169cb954 /compiler/rename/RnExpr.lhs | |
parent | 303776ab1ff8e192fe42374c8547b7c77305796e (diff) | |
download | haskell-0f930ba2039e28d0083780a58adb37ff01a92019.tar.gz |
Move expansion of 'assert' from renamer to typechecker
This improves error messages when there is a type error,
fixing Trac #9774
Diffstat (limited to 'compiler/rename/RnExpr.lhs')
-rw-r--r-- | compiler/rename/RnExpr.lhs | 38 |
1 files changed, 1 insertions, 37 deletions
diff --git a/compiler/rename/RnExpr.lhs b/compiler/rename/RnExpr.lhs index 79a944fb2f..b24956c85e 100644 --- a/compiler/rename/RnExpr.lhs +++ b/compiler/rename/RnExpr.lhs @@ -79,17 +79,11 @@ rnExpr :: HsExpr RdrName -> RnM (HsExpr Name, FreeVars) finishHsVar :: Name -> RnM (HsExpr Name, FreeVars) -- Separated from rnExpr because it's also used -- when renaming infix expressions --- See Note [Adding the implicit parameter to 'assert'] finishHsVar name = do { this_mod <- getModule ; when (nameIsLocalOrFrom this_mod name) $ checkThLocalName name - - ; ignore_asserts <- goptM Opt_IgnoreAsserts - ; if ignore_asserts || not (name `hasKey` assertIdKey) - then return (HsVar name, unitFV name) - else do { e <- mkAssertErrorExpr - ; return (e, unitFV name) } } + ; return (HsVar name, unitFV name) } rnExpr (HsVar v) = do { mb_name <- lookupOccRn_maybe v @@ -1143,36 +1137,6 @@ segsToStmts empty_rec_stmt ((defs, uses, fwds, ss) : segs) fvs_later %************************************************************************ %* * -\subsubsection{Assertion utils} -%* * -%************************************************************************ - -\begin{code} -srcSpanPrimLit :: DynFlags -> SrcSpan -> HsExpr Name -srcSpanPrimLit dflags span - = HsLit (HsStringPrim (unsafeMkByteString (showSDocOneLine dflags (ppr span)))) - -mkAssertErrorExpr :: RnM (HsExpr Name) --- Return an expression for (assertError "Foo.hs:27") -mkAssertErrorExpr - = do sloc <- getSrcSpanM - dflags <- getDynFlags - return (HsApp (L sloc (HsVar assertErrorName)) - (L sloc (srcSpanPrimLit dflags sloc))) -\end{code} - -Note [Adding the implicit parameter to 'assert'] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The renamer transforms (assert e1 e2) to (assert "Foo.hs:27" e1 e2). -By doing this in the renamer we allow the typechecker to just see the -expanded application and do the right thing. But it's not really -the Right Thing because there's no way to "undo" if you want to see -the original source code. We'll have fix this in due course, when -we care more about being able to reconstruct the exact original -program. - -%************************************************************************ -%* * \subsubsection{Errors} %* * %************************************************************************ |