diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2022-02-08 16:23:43 +0000 |
---|---|---|
committer | Matthew Pickering <matthewtpickering@gmail.com> | 2022-02-28 09:26:17 +0000 |
commit | a8afcc1762130dab0c88adebcaaf459623f56d04 (patch) | |
tree | c65709f0b797684e65a21e90a11b02e342ece43b | |
parent | 70bafefbfc5fc31d5fad3184fc9bdc623871923b (diff) | |
download | haskell-wip/ghc-annot.tar.gz |
Make -dannot-lint not panic on let bound type variableswip/ghc-annot
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.hs | 9 |
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 |