[Git][ghc/ghc][wip/T23025] Don't add external names to the usage environment

Krzysztof Gogolewski (@monoidal) gitlab at gitlab.haskell.org
Wed Apr 26 12:07:39 UTC 2023



Krzysztof Gogolewski pushed to branch wip/T23025 at Glasgow Haskell Compiler / GHC


Commits:
e9a5a9b4 by Krzysztof Gogolewski at 2023-04-26T14:07:16+02:00
Don't add external names to the usage environment

- - - - -


2 changed files:

- compiler/GHC/Core/Lint.hs
- compiler/GHC/Tc/Gen/Head.hs


Changes:

=====================================
compiler/GHC/Core/Lint.hs
=====================================
@@ -1025,7 +1025,11 @@ lintIdOcc var nargs
              Nothing -> return ()
              Just dc -> checkTypeDataConOcc "expression" dc
 
-        ; usage <- varCallSiteUsage var
+          -- Don't add external names to the usage environment;
+          -- they are not relevant for linearity checks
+        ; usage <- case isExternalName (Var.varName var) of
+                     False -> varCallSiteUsage var
+                     True -> return zeroUE
 
         ; return (linted_bndr_ty, usage) }
 


=====================================
compiler/GHC/Tc/Gen/Head.hs
=====================================
@@ -1091,7 +1091,10 @@ tc_infer_id id_name
 check_local_id :: Id -> TcM ()
 check_local_id id
   = do { checkThLocalId id
-       ; tcEmitBindingUsage $ unitUE (idName id) OneTy }
+         -- Don't add external names to the usage environment;
+         -- they are not relevant for linearity checks
+       ; unless (isExternalName (idName id)) $
+           tcEmitBindingUsage $ unitUE (idName id) OneTy }
 
 check_naughty :: OccName -> TcId -> TcM ()
 check_naughty lbl id



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e9a5a9b4e27df4d13f4cb44a389f7afef885c5d5
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/20230426/6c071c8d/attachment-0001.html>


More information about the ghc-commits mailing list