[Git][ghc/ghc][wip/ghc-9.8] 14 commits: Fix deprecation of record fields

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Fri Jul 21 15:06:22 UTC 2023



Ben Gamari pushed to branch wip/ghc-9.8 at Glasgow Haskell Compiler / GHC


Commits:
3d913cbe by sheaf at 2023-07-20T15:29:21-04:00
Fix deprecation of record fields

Commit 3f374399 inadvertently broke the deprecation/warning mechanism
for record fields due to its introduction of record field namespaces.

This patch ensures that, when a top-level deprecation is applied to
an identifier, it applies to all the record fields as well.
This is achieved by refactoring GHC.Rename.Env.lookupLocalTcNames, and
GHC.Rename.Env.lookupBindGroupOcc, to not look up a fixed number of
NameSpaces but to look up all NameSpaces and filter out the irrelevant
ones.

(cherry picked from commit 6143838a5985ee3af1e8c2af4166d35bb4de12d8)

- - - - -
45ab7560 by sheaf at 2023-07-20T15:29:24-04:00
Introduce greInfo, greParent

These are simple helper functions that wrap the internal
field names gre_info, gre_par.

(cherry picked from commit 6fd8f566c691b936b0b65e21700b224312611f4d)

- - - - -
c5533204 by sheaf at 2023-07-20T15:29:25-04:00
Refactor lookupGRE_... functions

This commit consolidates all the logic for looking up something in
the Global Reader Environment into the single function lookupGRE.
This allows us to declaratively specify all the different modes of
looking up in the GlobalRdrEnv, and avoids manually passing around
filtering functions as was the case in e.g. the function
GHC.Rename.Env.lookupSubBndrOcc_helper.

-------------------------
Metric Decrease:
    T8095
-------------------------
-------------------------
Metric Increase:
    T8095
-------------------------

(cherry picked from commit 7f0a86edeeda674f27c80e81be592d325447a897)

- - - - -
ff06b820 by sheaf at 2023-07-20T15:30:07-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

(cherry picked from commit c7bbad9a0aab2d7b4336ae411e13d9450d8483a7)

- - - - -
2734d370 by sheaf at 2023-07-20T15:34:20-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.

(cherry picked from commit 1af2e7735283251c686bdb1154afab6df5e45053)

- - - - -
84e6df59 by sheaf at 2023-07-20T15:34:20-04:00
Prioritise Parent when looking up class sub-binder

When we look up children GlobalRdrElts of a given Parent, we sometimes
would rather prioritise those GlobalRdrElts which have the right Parent,
and sometimes prioritise those that have the right NameSpace:

  - in export lists, we should prioritise NameSpace
  - for class/instance binders, we should prioritise Parent

See Note [childGREPriority] in GHC.Types.Name.Reader.

fixes #23664

(cherry picked from commit 3bd4d5b5482fd44914f22492877b3f3ca27299e0)

- - - - -
fa084def by sheaf at 2023-07-20T15:34:33-04:00
base: add COMPLETE pragma to BufferCodec PatSyn

This implements CLC proposal #178, rectifying an oversight in the
implementation of CLC proposal #134 which could lead to spurious
pattern match warnings.

https://github.com/haskell/core-libraries-committee/issues/178
https://github.com/haskell/core-libraries-committee/issues/134
(cherry picked from commit 22565506515313c928d13a43b2946e0106110353)

- - - - -
f9f4714e by sheaf at 2023-07-20T15:34:34-04:00
exactprint: silence incomplete record update warnings

(cherry picked from commit 860f6269bc016e11400b7e3176a5ea6dfe291a46)

- - - - -
071dd8ca by sheaf at 2023-07-20T15:35:45-04:00
Re-instate -Wincomplete-record-updates

Commit e74fc066 refactored the handling of record updates to use
the HsExpanded mechanism. This meant that the pattern matching inherent
to a record update was considered to be "generated code", and thus we
stopped emitting "incomplete record update" warnings entirely.

This commit changes the "data Origin = Source | Generated" datatype,
adding a field to the Generated constructor to indicate whether we
still want to perform pattern-match checking. We also have to do a bit
of plumbing with HsCase, to record that the HsCase arose from an
HsExpansion of a RecUpd, so that the error message continues to mention
record updates as opposed to a generic "incomplete pattern matches in case"
error.

Finally, this patch also changes the way we handle inaccessible code
warnings. Commit e74fc066 was also a regression in this regard, as we
were emitting "inaccessible code" warnings for case statements spuriously
generated when desugaring a record update (remember: the desugaring mechanism
happens before typechecking; it thus can't take into account e.g. GADT information
in order to decide which constructors to include in the RHS of the desugaring
of the record update).
We fix this by changing the mechanism through which we disable inaccessible
code warnings: we now check whether we are in generated code in
GHC.Tc.Utils.TcMType.newImplication in order to determine whether to
emit inaccessible code warnings.

Fixes #23520
Updates haddock submodule, to avoid incomplete record update warnings

(cherry picked from commit df706de378e3415a3972ddd14863f54fc7162dc7)

- - - - -
c7688443 by sheaf at 2023-07-20T15:35:55-04:00
Propagate long-distance information in do-notation

The preceding commit re-enabled pattern-match checking inside record
updates. This revealed that #21360 was in fact NOT fixed by e74fc066.

This commit makes sure we correctly propagate long-distance information
in do blocks, e.g. in

```haskell
data T = A { fld :: Int } | B

f :: T -> Maybe T
f r = do
  a at A{} <- Just r
  Just $ case a of { A _ -> A 9 }
```

we need to propagate the fact that "a" is headed by the constructor "A"
to see that the case expression "case a of { A _ -> A 9 }" cannot fail.

Fixes #21360

(cherry picked from commit 1d05971e24f6cb1120789d1e1ab4f086eebd504a)

- - - - -
ae88ed9a by sheaf at 2023-07-20T15:35:56-04:00
Skip PMC for boring patterns

Some patterns introduce no new information to the pattern-match
checker (such as plain variable or wildcard patterns). We can thus
skip doing any pattern-match checking on them when the sole purpose
for doing so was introducing new long-distance information.

See Note [Boring patterns] in GHC.Hs.Pat.

Doing this avoids regressing in performance now that we do additional
pattern-match checking inside do notation.

(cherry picked from commit bea0e323c09e9e4b841a37aacd6b67e87a85e7cb)

- - - - -
f00446f5 by Ben Gamari at 2023-07-21T15:04:43+00:00
gitlab-ci: Don't run nonmoving bootstrap release job

This was only intended for validation.

- - - - -
c9e18bb7 by Ben Gamari at 2023-07-21T15:05:04+00:00
fetch-gitlab: Update job mapping

- - - - -
7c5386d2 by Ben Gamari at 2023-07-21T15:05:34+00:00
nofib: Bump submodule

- - - - -


30 changed files:

- .gitlab/gen_ci.hs
- .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py
- compiler/GHC/Data/FastString.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Pat.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Arrows.hs
- compiler/GHC/HsToCore/Errors/Ppr.hs
- compiler/GHC/HsToCore/Errors/Types.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/GuardedRHSs.hs
- compiler/GHC/HsToCore/ListComp.hs
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Match.hs-boot
- compiler/GHC/HsToCore/Match/Constructor.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc.hs
- compiler/GHC/HsToCore/Pmc/Utils.hs
- compiler/GHC/HsToCore/Utils.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Rename/Doc.hs
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Unbound.hs
- compiler/GHC/Rename/Utils.hs
- compiler/GHC/Runtime/Loader.hs
- compiler/GHC/Tc/Deriv/Generate.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ccb9981bf74b78194d9baef9d9483235968b8849...7c5386d29626759a8cca561811acc514e57c603e

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ccb9981bf74b78194d9baef9d9483235968b8849...7c5386d29626759a8cca561811acc514e57c603e
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/20230721/f0d201c8/attachment-0001.html>


More information about the ghc-commits mailing list