summaryrefslogtreecommitdiff
path: root/compiler/rename/RnSource.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2018-09-20 19:53:56 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2018-09-23 02:45:23 +0100
commitcad5d0b69bc039b635a6eb0e5c9ed47d7c5a38ed (patch)
treee245f11c6cb56e4422a9e0875ceacd93c3ef4096 /compiler/rename/RnSource.hs
parent7e77f41430ae1cad84d5b0c90328331d38f3eda0 (diff)
downloadhaskell-cad5d0b69bc039b635a6eb0e5c9ed47d7c5a38ed.tar.gz
Buglet in reporting out of scope errors in rules
Most out of scope errors get reported by the type checker these days, but not all. Example, the function on the LHS of a RULE. Trace #15659 pointed out that this less-heavily-used code path produce a "wacky" error message. Indeed so. Easily fixed.
Diffstat (limited to 'compiler/rename/RnSource.hs')
-rw-r--r--compiler/rename/RnSource.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rename/RnSource.hs b/compiler/rename/RnSource.hs
index 00fc3351e5..91c46b3cc4 100644
--- a/compiler/rename/RnSource.hs
+++ b/compiler/rename/RnSource.hs
@@ -29,7 +29,7 @@ import RnUtils ( HsDocContext(..), mapFvRn, bindLocalNames
, checkDupRdrNames, inHsDocContext, bindLocalNamesFV
, checkShadowedRdrNames, warnUnusedTypePatterns
, extendTyVarEnvFVRn, newLocalBndrsRn )
-import RnUnbound ( mkUnboundName )
+import RnUnbound ( mkUnboundName, notInScopeErr )
import RnNames
import RnHsDoc ( rnHsDoc, rnMbLHsDoc )
import TcAnnotations ( annCtxt )
@@ -1093,14 +1093,14 @@ badRuleVar name var
badRuleLhsErr :: FastString -> LHsExpr GhcRn -> HsExpr GhcRn -> SDoc
badRuleLhsErr name lhs bad_e
= sep [text "Rule" <+> pprRuleName name <> colon,
- nest 4 (vcat [err,
+ nest 2 (vcat [err,
text "in left-hand side:" <+> ppr lhs])]
$$
text "LHS must be of form (f e1 .. en) where f is not forall'd"
where
err = case bad_e of
- HsUnboundVar _ uv -> text "Not in scope:" <+> ppr uv
- _ -> text "Illegal expression:" <+> ppr bad_e
+ HsUnboundVar _ uv -> notInScopeErr (mkRdrUnqual (unboundVarOcc uv))
+ _ -> text "Illegal expression:" <+> ppr bad_e
{- **************************************************************
* *