[Git][ghc/ghc][wip/az/locateda-epa-improve-2023-07-15] 33 commits: Equality of forall-types is visibility aware
Alan Zimmerman (@alanz)
gitlab at gitlab.haskell.org
Mon Jul 17 21:32:55 UTC 2023
Alan Zimmerman pushed to branch wip/az/locateda-epa-improve-2023-07-15 at Glasgow Haskell Compiler / GHC
Commits:
cf86f3ec by Matthew Craven at 2023-07-16T01:42:09+02:00
Equality of forall-types is visibility aware
This patch finally (I hope) nails the question of whether
(forall a. ty) and (forall a -> ty)
are `eqType`: they aren't!
There is a long discussion in #22762, plus useful Notes:
* Note [ForAllTy and type equality] in GHC.Core.TyCo.Compare
* Note [Comparing visiblities] in GHC.Core.TyCo.Compare
* Note [ForAllCo] in GHC.Core.TyCo.Rep
It also establishes a helpful new invariant for ForAllCo,
and ForAllTy, when the bound variable is a CoVar:in that
case the visibility must be coreTyLamForAllTyFlag.
All this is well documented in revised Notes.
- - - - -
7f13acbf by Vladislav Zavialov at 2023-07-16T01:56:27-04:00
List and Tuple<n>: update documentation
Add the missing changelog.md entries and @since-annotations.
- - - - -
2afbddb0 by Andrei Borzenkov at 2023-07-16T10:21:24+04:00
Type patterns (#22478, #18986)
Improved name resolution and type checking of type patterns in constructors:
1. HsTyPat: a new dedicated data type that represents type patterns in
HsConPatDetails instead of reusing HsPatSigType
2. rnHsTyPat: a new function that renames a type
pattern and collects its binders into three groups:
- explicitly bound type variables, excluding locally bound
variables
- implicitly bound type variables from kind signatures
(only if ScopedTypeVariables are enabled)
- named wildcards (only from kind signatures)
2a. rnHsPatSigTypeBindingVars: removed in favour of rnHsTyPat
2b. rnImplcitTvBndrs: removed because no longer needed
3. collect_pat: updated to collect type variable binders from type patterns
(this means that types and terms use the same infrastructure to detect
conflicting bindings, unused variables and name shadowing)
3a. CollVarTyVarBinders: a new CollectFlag constructor that enables
collection of type variables
4. tcHsTyPat: a new function that typechecks type patterns, capable of
handling polymorphic kinds.
See Note [Type patterns: binders and unifiers]
Examples of code that is now accepted:
f = \(P @a) -> \(P @a) -> ... -- triggers -Wname-shadowing
g :: forall a. Proxy a -> ...
g (P @a) = ... -- also triggers -Wname-shadowing
h (P @($(TH.varT (TH.mkName "t")))) = ...
-- t is bound at splice time
j (P @(a :: (x,x))) = ... -- (x,x) is no longer rejected
data T where
MkT :: forall (f :: forall k. k -> Type).
f Int -> f Maybe -> T
k :: T -> ()
k (MkT @f (x :: f Int) (y :: f Maybe)) = ()
-- f :: forall k. k -> Type
Examples of code that is rejected with better error messages:
f (Left @a @a _) = ...
-- new message:
-- • Conflicting definitions for ‘a’
-- Bound at: Test.hs:1:11
-- Test.hs:1:14
Examples of code that is now rejected:
{-# OPTIONS_GHC -Werror=unused-matches #-}
f (P @a) = ()
-- Defined but not used: type variable ‘a’
- - - - -
eb1a6ab1 by sheaf at 2023-07-16T09:20:45-04:00
Don't use substTyUnchecked in newMetaTyVar
There were some comments that explained that we needed to use an
unchecked substitution function because of issue #12931, but that
has since been fixed, so we should be able to use substTy instead now.
- - - - -
c7bbad9a by sheaf at 2023-07-17T02:48:19-04:00
rnImports: var shouldn't import NoFldSelectors
In an import declaration such as
import M ( var )
the import of the variable "var" should **not** bring into scope record
fields named "var" which are defined with NoFieldSelectors.
Doing so can cause spurious "unused import" warnings, as reported in
ticket #23557.
Fixes #23557
- - - - -
1af2e773 by sheaf at 2023-07-17T02:48:19-04:00
Suggest similar names in imports
This commit adds similar name suggestions when importing. For example
module A where { spelling = 'o' }
module B where { import B ( speling ) }
will give rise to the error message:
Module ‘A’ does not export ‘speling’.
Suggested fix: Perhaps use ‘spelling’
This also provides hints when users try to import record fields defined
with NoFieldSelectors.
- - - - -
654fdb98 by Alan Zimmerman at 2023-07-17T02:48:55-04:00
EPA: Store leading AnnSemi for decllist in al_rest
This simplifies the markAnnListA implementation in ExactPrint
- - - - -
d328cb00 by Alan Zimmerman at 2023-07-17T17:55:25+01:00
EPA: Improve annotation management in getMonoBind
Ensure the LHsDecl for a FunBind has the correct leading comments and
trailing annotations.
See the added note for details.
- - - - -
0c4e5953 by Alan Zimmerman at 2023-07-17T18:03:17+01:00
EPA: Simplify GHC/Parser.y sL1
This is the next patch in a series simplifying location management in
GHC/Parser.y
This one simplifies sL1, to use the HasLoc instances introduced in
!10743 (closed)
- - - - -
dc6127a5 by Alan Zimmerman at 2023-07-17T18:12:24+01:00
Summary: epa-improve-comb4-5
Author: Alan Zimmerman <alan.zimm at gmail.com>
Date: 2023-06-27 23:08:05 +0100
EPA: Simplify GHC/Parser.y comb4/comb5
Use the HasLoc instance from Ast.hs to allow comb4/comb5 to work with
anything with a SrcSpan
Also get rid of some more now unnecessary reLoc calls.
- - - - -
885702cc by Alan Zimmerman at 2023-07-17T20:36:47+01:00
EPA: Provide correct annotation span for ImportDecl
Use the whole declaration, rather than just the span of the 'import'
keyword.
- - - - -
5b7a0a1f by Alan Zimmerman at 2023-07-17T20:36:53+01:00
Summary: EPA make getLocA a synonym for getHasLoc
Author: Alan Zimmerman <alan.zimm at gmail.com>
Date: 2023-07-16 09:25:10 +0100
EPA make getLocA a synonym for getHasLoc
- - - - -
266ed2b4 by Alan Zimmerman at 2023-07-17T20:46:35+01:00
EPA: Fix span for GRHS
- - - - -
1846be0a by Alan Zimmerman at 2023-07-17T21:40:14+01:00
EPA: Capture full range for a CaseAlt Match
- - - - -
8fb7a663 by Alan Zimmerman at 2023-07-17T21:46:22+01:00
Put BufSpan into RealSrcSpan
This has been superseded by !9473, which moved BufSpan into EpaSpan in
EpaLocation
Start on making LocatedN more direct
Using EpaLocation instead of Anchor
Via a synonym initially, to prove the concept
Variants of AnnSortKey
For future, just a list of which type comes next.
Example for ValBinds
EPA: Explicitly capture EOF Location in AnnsModule
And also get rid of EpaEofComment.
- - - - -
1a117f37 by Alan Zimmerman at 2023-07-17T21:46:29+01:00
[EPA] Simplify noAnnSrcSpanDP0
- - - - -
235cb951 by Alan Zimmerman at 2023-07-17T21:46:29+01:00
Clean up addTrailingCommaN
Remove unused parameter
- - - - -
7d8652dc by Alan Zimmerman at 2023-07-17T21:46:29+01:00
WIP
- - - - -
99129e91 by Alan Zimmerman at 2023-07-17T21:46:29+01:00
[EPA] Introduce HasTrailing in ExactPrint
Just plumbed through, not being used yet
- - - - -
5d6ff670 by Alan Zimmerman at 2023-07-17T21:46:29+01:00
EPA use [TrailingAnn] in enterAnn
And remove it from ExactPrint (LocatedN RdrName)
- - - - -
50827219 by Alan Zimmerman at 2023-07-17T21:46:29+01:00
EPA Use full range for Anchor, and do not widen for [TrailingAnn]
- - - - -
475ce32b by Alan Zimmerman at 2023-07-17T21:46:30+01:00
EPA: Move TrailingAnns from last match to FunBind
- - - - -
1c9c062f by Alan Zimmerman at 2023-07-17T21:46:30+01:00
EPA: In HsDo, put TrailingAnns at top of LastStmt
- - - - -
0aa8a500 by Alan Zimmerman at 2023-07-17T21:46:30+01:00
EPA: More extending anchors to full span in Parser.y
- - - - -
8fb7dad6 by Alan Zimmerman at 2023-07-17T21:46:30+01:00
EPA: Move TrailingAnns to the top of FieldOcc
- - - - -
ed88b0a1 by Alan Zimmerman at 2023-07-17T21:46:30+01:00
EPA: Fix simple tests
- - - - -
f9507c9d by Alan Zimmerman at 2023-07-17T21:46:30+01:00
EPA: do not convert comments to deltas when balancing.
It seems its not needed with the new approach
- - - - -
56bb7f32 by Alan Zimmerman at 2023-07-17T21:46:30+01:00
EPA: Improve annotation management in getMonoBind
Ensure the LHsDecl for a FunBind has the correct leading comments and
trailing annotations.
See the added note for details.
- - - - -
92f2e12c by Alan Zimmerman at 2023-07-17T21:46:30+01:00
EPA: deal with fallout from getMonoBind
- - - - -
b732e004 by Alan Zimmerman at 2023-07-17T21:46:30+01:00
EPA fix captureLineSpacing
- - - - -
f1811bdc by Alan Zimmerman at 2023-07-17T21:46:30+01:00
EPA print any comments in the span before exiting it
- - - - -
a297a648 by Alan Zimmerman at 2023-07-17T21:46:30+01:00
EPA: getting rid of tweakDelta
WIP at present
- - - - -
c243e62e by Alan Zimmerman at 2023-07-17T22:31:13+01:00
EPA: Add '=>' to TrailingAnn
This is used as a trailing annotation in a context.
Add its normal and unicode variants.
Note that we keep the parsed representation the same, but make use of
it when exact printing.
- - - - -
30 changed files:
- compiler/GHC/Core/Coercion.hs
- compiler/GHC/Core/Coercion.hs-boot
- compiler/GHC/Core/Coercion/Opt.hs
- compiler/GHC/Core/FVs.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Opt/Arity.hs
- compiler/GHC/Core/Reduction.hs
- compiler/GHC/Core/TyCo/Compare.hs
- compiler/GHC/Core/TyCo/FVs.hs
- compiler/GHC/Core/TyCo/FVs.hs-boot
- compiler/GHC/Core/TyCo/Rep.hs
- compiler/GHC/Core/TyCo/Subst.hs
- compiler/GHC/Core/TyCo/Tidy.hs
- compiler/GHC/Core/Type.hs
- compiler/GHC/Core/Unify.hs
- compiler/GHC/Core/Utils.hs
- compiler/GHC/CoreToIface.hs
- compiler/GHC/Data/BooleanFormula.hs
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Hs/Binds.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Dump.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Extension.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Pat.hs
- compiler/GHC/Hs/Type.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Arrows.hs
- compiler/GHC/HsToCore/Docs.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/220903519e0ab34b8903fc13039037e0b3721070...c243e62ebd1ac44f332d0538e3273cf2de8ae80c
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/220903519e0ab34b8903fc13039037e0b3721070...c243e62ebd1ac44f332d0538e3273cf2de8ae80c
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/20230717/c738b49f/attachment-0001.html>
More information about the ghc-commits
mailing list