-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add NoFieldSelectors example to GHC-76037
- Loading branch information
1 parent
35f4d3d
commit ecf719a
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
message-index/messages/GHC-76037/example4/after/NoFieldSelectorsExport.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{-# LANGUAGE NoFieldSelectors #-} | ||
|
||
module NoFieldSelectorsExport (T (foo)) where | ||
|
||
data T = MkT { foo :: T } |
5 changes: 5 additions & 0 deletions
5
message-index/messages/GHC-76037/example4/before/NoFieldSelectorsExport.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{-# LANGUAGE NoFieldSelectors #-} | ||
|
||
module NoFieldSelectorsExport (T, foo) where | ||
|
||
data T = MkT { foo :: T } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
title: Field selector exported with NoFieldSelectors | ||
--- | ||
|
||
## Error Message | ||
|
||
``` | ||
NoFieldSelectorsExport.hs:3:35: error: [GHC-76037] | ||
Not in scope: ‘foo’ | ||
Suggested fix: | ||
Notice that ‘foo’ is a field selector belonging to the type ‘T’ | ||
that has been suppressed by NoFieldSelectors. | ||
| | ||
3 | module NoFieldSelectorsExport (T, foo) where | ||
| ^^^ | ||
``` | ||
|
||
## Explanation | ||
|
||
The field selector `foo` has been disabled via `NoFieldSelectors`, therefore it cannot be a top-level export. The fix is to export it as part of its type `T` (consequently it can be imported for e.g. record creation or updates). |