diff options
author | Ben Price <ben@brprice.uk> | 2020-02-26 12:56:42 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-03-10 12:30:27 -0400 |
commit | 5ba01d83a2078acce789a9d5f111efa4d4ffc616 (patch) | |
tree | 1525361817867f6c1038e5747b9589b475b4ddf3 | |
parent | 5fa9cb82223de1c1c2684aa6917bf85a2e3c6469 (diff) | |
download | haskell-5ba01d83a2078acce789a9d5f111efa4d4ffc616.tar.gz |
Clarify a Lint message
When developing a plugin I had a shadowing problem, where I generated
code
app = \f{v r7B} x{v r7B} -> f{v r7B} x{v r7B}
This is obviously wrong, since the occurrence of `f` to the right of the
arrow refers to the `x` binder (they share a Unique). However, it is
rather confusing when Lint reports
Mismatch in type between binder and occurrence
Var: x{v rB7}
since it is printing the binder, rather than the occurrence.
It is rather easy to read this as claiming there is something wrong with
the `x` occurrence!
We change the report to explicitly print both the binder and the
occurrence variables.
-rw-r--r-- | compiler/GHC/Core/Lint.hs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/compiler/GHC/Core/Lint.hs b/compiler/GHC/Core/Lint.hs index dc4119dea8..091e4d8571 100644 --- a/compiler/GHC/Core/Lint.hs +++ b/compiler/GHC/Core/Lint.hs @@ -2729,9 +2729,8 @@ mkJoinBndrOccMismatchMsg bndr join_arity_bndr join_arity_occ mkBndrOccTypeMismatchMsg :: Var -> Var -> OutType -> OutType -> SDoc mkBndrOccTypeMismatchMsg bndr var bndr_ty var_ty = vcat [ text "Mismatch in type between binder and occurrence" - , text "Var:" <+> ppr bndr - , text "Binder type:" <+> ppr bndr_ty - , text "Occurrence type:" <+> ppr var_ty + , text "Binder:" <+> ppr bndr <+> dcolon <+> ppr bndr_ty + , text "Occurrence:" <+> ppr var <+> dcolon <+> ppr var_ty , text " Before subst:" <+> ppr (idType var) ] mkBadJoinPointRuleMsg :: JoinId -> JoinArity -> CoreRule -> SDoc |