[Git][ghc/ghc][wip/T22717] 4 commits: Detect family instance orphans correctly

sheaf (@sheaf) gitlab at gitlab.haskell.org
Thu Jan 26 14:10:24 UTC 2023



sheaf pushed to branch wip/T22717 at Glasgow Haskell Compiler / GHC


Commits:
a1857977 by Simon Peyton Jones at 2023-01-26T15:10:23+01:00
Detect family instance orphans correctly

This MR fixes two bugs, both in #22717.

1. We were treating a type-family instance as a non-orphan if there
   was a type constructor on it /right-hand side/ that was local.Boo!
   Utterly wrong.

   The fix is trivial: look only at the LHS

2. We were not reporting orphan family instances at all.

   The fix here is easy, but touches more code. I refactored it to
   be much more similar to the way that class instances are done.

   - Add a fi_orphan field to FamInst, like the is_orphan field in ClsInst
   - Make newFamInst initialise this field, just like newClsInst
   - And make newFamInst report a warning for an orphan, just like newClsInst
   - I moved newFamInst from GHC.Tc.Instance.Family to GHC.Tc.Utils.Instantiate,
     just like newClsInst.
   - I added mkLocalFamInst to FamInstEnv, just like mkLocalClsInst in InstEnv
   - I added a new error constructor TcRnOrphanFamInst, and renamed
     the existing TcRnOrphanInstance to TcRnOrphanClsInst
   - Ditto SuggestFixOrphanFamInst

Fixes #22717
Fixes #19773

- - - - -
45744c76 by Simon Peyton Jones at 2023-01-26T15:10:23+01:00
Avoid orphans in STG

This patch removes some orphan instances in the STG namespace
by introducing the GHC.Stg.Lift.Types module, which allows various
type family instances to be moved to GHC.Stg.Syntax, avoiding orphan
instances.

- - - - -
724da6b7 by Simon Peyton Jones at 2023-01-26T15:10:23+01:00
Avoid orphans in the parser

This moves Anno instances for PatBuilder from GHC.Parser.PostProcess
to GHC.Parser.Types to avoid orphans.

- - - - -
4a1f47f9 by Simon Peyton Jones at 2023-01-26T15:10:23+01:00
Accept an orphan declaration (sadly)

This accepts the orphan type family instance

  type instance DsForeignHook = ...

in GHC.HsToCore.Types.

See Note [The Decoupling Abstract Data Hack] in GHC.Driver.Hooks

- - - - -


30 changed files:

- compiler/GHC.hs
- compiler/GHC/Core.hs
- compiler/GHC/Core/FVs.hs
- compiler/GHC/Core/FamInstEnv.hs
- compiler/GHC/Core/InstEnv.hs
- compiler/GHC/Driver/Hooks.hs
- compiler/GHC/HsToCore/Types.hs
- compiler/GHC/Iface/Make.hs
- compiler/GHC/IfaceToCore.hs
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Parser/Types.hs
- compiler/GHC/Runtime/Eval.hs
- compiler/GHC/Stg/InferTags/TagSig.hs
- compiler/GHC/Stg/InferTags/Types.hs
- compiler/GHC/Stg/Lift/Analysis.hs
- + compiler/GHC/Stg/Lift/Types.hs
- compiler/GHC/Stg/Pipeline.hs
- compiler/GHC/Stg/Syntax.hs
- compiler/GHC/Tc/Deriv/Generate.hs
- compiler/GHC/Tc/Deriv/Generics.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Instance/Family.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/TyCl/Class.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Tc/Utils/TcType.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/Hint.hs
- compiler/GHC/Types/Hint/Ppr.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/81f69897c7ac70d072782c1a4d9890838969f835...4a1f47f9975c53f95617ccd783477fdda500b9e4

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/81f69897c7ac70d072782c1a4d9890838969f835...4a1f47f9975c53f95617ccd783477fdda500b9e4
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/20230126/c00c94f8/attachment.html>


More information about the ghc-commits mailing list