Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document GHC-61689; Add examples to GHC-88464 and GHC-76037 #477

Merged
merged 3 commits into from
Feb 25, 2024

Conversation

tbidne
Copy link
Contributor

@tbidne tbidne commented Feb 23, 2024

Hello!

I recently ran into the error like

E2NoFieldSelectors.hs:11:24: error: [GHC-61689]
    Module ‘A’ does not export ‘fint’.
    Suggested fix:
      Notice that ‘fint’ is a field selector belonging to the type ‘A.Foo’
      that has been suppressed by NoFieldSelectors.
   |
11 | import A (Foo (MkFoo), fint)
   |                        ^^^^

And I found the various nuances confusing enough that I thought it merited a description here. It turns out there are multiple errors that can trigger this message.

GHC-61689 (New)

This is a new error introduced in GHC 9.8.1 for importing a an unexported symbol.

-- GHC-61689, fint is a field selector disabled with NoFieldSelectors, always an error
import A (Foo (MkFoo), fint)

GHC-88464

This was previously documented in other cases, but it can also trigger the NoFieldSelectors message in the right circumstances.

-- GHC-88464, error if fint is used as a selector, OK otherwise
import A (Foo (MkFoo, fint))

getFooInt :: Foo -> Int
getFooInt = fint -- this is the problem

GHC-76037

Similar to GHC-61689, though it involves the export, not the import.

{-# LANGUAGE NoFieldSelectors #-}

-- GHC-76037, error if foo is exported at the top-level rather than part of T.
module NoFieldSelectorsExport (T, foo) where

data T = MkT { foo :: T }

I have this in the same PR as they are all related, but please let me know if they should be split up, or if there should be issues created. Thanks!

Copy link
Collaborator

@jhrcek jhrcek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The examples and explanations look good. Few minor suggestions.

@tbidne tbidne force-pushed the ghc-61689 branch 2 times, most recently from 35f485f to b8bd878 Compare February 24, 2024 08:15
Copy link
Collaborator

@jhrcek jhrcek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good to me.

@tbidne
Copy link
Contributor Author

tbidne commented Feb 24, 2024

Thanks for the review!

@BinderDavid BinderDavid merged commit ecf719a into haskellfoundation:main Feb 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants