[Git][ghc/ghc][master] Lint: more details on "Occurrence is GlobalId, but binding is LocalId"

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Fri Jun 16 09:52:57 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
62c56416 by Ben Price at 2023-06-16T05:52:39-04:00
Lint: more details on "Occurrence is GlobalId, but binding is LocalId"

This is helpful when debugging a pass which accidentally shadowed a
binder.

- - - - -


1 changed file:

- compiler/GHC/Core/Lint.hs


Changes:

=====================================
compiler/GHC/Core/Lint.hs
=====================================
@@ -3243,7 +3243,7 @@ lookupIdInScope id_occ
   = do { in_scope_ids <- getInScopeIds
        ; case lookupVarEnv in_scope_ids id_occ of
            Just (id_bndr, linted_ty)
-             -> do { checkL (not (bad_global id_bndr)) global_in_scope
+             -> do { checkL (not (bad_global id_bndr)) $ global_in_scope id_bndr
                    ; return (id_bndr, linted_ty) }
            Nothing -> do { checkL (not is_local) local_out_of_scope
                          ; return (id_occ, idType id_occ) } }
@@ -3252,8 +3252,10 @@ lookupIdInScope id_occ
   where
     is_local = mustHaveLocalBinding id_occ
     local_out_of_scope = text "Out of scope:" <+> pprBndr LetBind id_occ
-    global_in_scope    = hang (text "Occurrence is GlobalId, but binding is LocalId")
-                            2 (pprBndr LetBind id_occ)
+    global_in_scope id_bndr = hang (text "Occurrence is GlobalId, but binding is LocalId")
+                                 2 $ vcat [hang (text "occurrence:") 2 $ pprBndr LetBind id_occ
+                                          ,hang (text "binder    :") 2 $ pprBndr LetBind id_bndr
+                                          ]
     bad_global id_bnd = isGlobalId id_occ
                      && isLocalId id_bnd
                      && not (isWiredIn id_occ)



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/62c5641679b38ecf1978da890e084ef435255903

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/62c5641679b38ecf1978da890e084ef435255903
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230616/51a1e101/attachment-0001.html>


More information about the ghc-commits mailing list