diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2018-09-20 19:53:56 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2018-09-23 02:45:23 +0100 |
commit | cad5d0b69bc039b635a6eb0e5c9ed47d7c5a38ed (patch) | |
tree | e245f11c6cb56e4422a9e0875ceacd93c3ef4096 /compiler/rename/RnUnbound.hs | |
parent | 7e77f41430ae1cad84d5b0c90328331d38f3eda0 (diff) | |
download | haskell-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/RnUnbound.hs')
-rw-r--r-- | compiler/rename/RnUnbound.hs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/rename/RnUnbound.hs b/compiler/rename/RnUnbound.hs index a77025fe7e..ce5d0dc315 100644 --- a/compiler/rename/RnUnbound.hs +++ b/compiler/rename/RnUnbound.hs @@ -12,7 +12,8 @@ module RnUnbound ( mkUnboundName , WhereLooking(..) , unboundName , unboundNameX - , perhapsForallMsg ) where + , perhapsForallMsg + , notInScopeErr ) where import GhcPrelude @@ -60,8 +61,7 @@ unboundNameX :: WhereLooking -> RdrName -> SDoc -> RnM Name unboundNameX where_look rdr_name extra = do { dflags <- getDynFlags ; let show_helpful_errors = gopt Opt_HelpfulErrors dflags - what = pprNonVarNameSpace (occNameSpace (rdrNameOcc rdr_name)) - err = unknownNameErr what rdr_name $$ extra + err = notInScopeErr rdr_name $$ extra ; if not show_helpful_errors then addErr err else do { local_env <- getLocalRdrEnv @@ -72,12 +72,13 @@ unboundNameX where_look rdr_name extra ; addErr (err $$ suggestions) } ; return (mkUnboundNameRdr rdr_name) } -unknownNameErr :: SDoc -> RdrName -> SDoc -unknownNameErr what rdr_name +notInScopeErr :: RdrName -> SDoc +notInScopeErr rdr_name = vcat [ hang (text "Not in scope:") 2 (what <+> quotes (ppr rdr_name)) , extra ] where + what = pprNonVarNameSpace (occNameSpace (rdrNameOcc rdr_name)) extra | rdr_name == forall_tv_RDR = perhapsForallMsg | otherwise = Outputable.empty |