summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-02-08 16:23:43 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-03-02 14:09:13 -0500
commit81b7c4361c0e3da403e0fcf42cc7faae2ca3db9a (patch)
tree71886afe57e4f4dc68b50e248eeaf188c3c74820
parentb27b2af3fab48e21aabcc9441967c4dd7a6a75ea (diff)
downloadhaskell-81b7c4361c0e3da403e0fcf42cc7faae2ca3db9a.tar.gz
Make -dannot-lint not panic on let bound type variables
After certain simplifier passes we end up with let bound type variables which are immediately inlined in the next pass. The core diff utility implemented by -dannot-lint failed to take these into account and paniced. Progress towards #20965
-rw-r--r--compiler/GHC/Core/Utils.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/GHC/Core/Utils.hs b/compiler/GHC/Core/Utils.hs
index 3116b6bd04..baefb7712b 100644
--- a/compiler/GHC/Core/Utils.hs
+++ b/compiler/GHC/Core/Utils.hs
@@ -2181,8 +2181,9 @@ diffBinds top env binds1 = go (length binds1) env binds1
else (warn env binds1 binds2, env)
go fuel env ((bndr1,expr1):binds1) binds2
| let matchExpr (bndr,expr) =
- (not top || null (diffIdInfo env bndr bndr1)) &&
+ (isTyVar bndr || not top || null (diffIdInfo env bndr bndr1)) &&
null (diffExpr top (rnBndr2 env bndr1 bndr) expr1 expr)
+
, (binds2l, (bndr2,_):binds2r) <- break matchExpr binds2
= go (length binds1) (rnBndr2 env bndr1 bndr2)
binds1 (binds2l ++ binds2r)
@@ -2205,6 +2206,12 @@ diffBinds top env binds1 = go (length binds1) env binds1
diffBind env (bndr1,expr1) (bndr2,expr2)
| ds@(_:_) <- diffExpr top env expr1 expr2
= locBind "in binding" bndr1 bndr2 ds
+ -- Special case for TyVar, which we checked were bound to the same types in
+ -- diffExpr, but don't have any IdInfo we would panic if called diffIdInfo.
+ -- These let-bound types are created temporarily by the simplifier but inlined
+ -- immediately.
+ | isTyVar bndr1 && isTyVar bndr2
+ = []
| otherwise
= diffIdInfo env bndr1 bndr2