Skip to content

Fix deprecation of record fields

sheaf requested to merge sheaf/ghc:T23279 into master

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.

In particular, instead of GHC.Rename.Env.dataTcOccs returning a set of RdrNames with their NameSpaces fixed up, it returns a function that allows us to filter out OccNames with irrelevant NameSpaces. The function is now called rdrRelevantNameSpace.

TODO:

  • Audit the call of lookupBindGroupOcc in lookupSigCtxtOccRn by looking at the uses of lookupSigCtxtOccRn.
  • Document the critical change in rnSrcWarnDecls where we must be sure to use the NameSpace of the Name we looked up rather than the NameSpace of the RdrName.

I am leaving the removal of dataTcOccs and refactoring of thRdrNameGuesses to a future MR, as it doesn't fix a live bug in the compiler and requires a bit more thought about the handling of wired-in names which live in multiple namespaces (vicinity of setWiredInNameSpace etc).

Edited by sheaf

Merge request reports