Skip to content

Commit ecf719a

Browse files
tbidneBinderDavid
authored andcommitted
Add NoFieldSelectors example to GHC-76037
1 parent 35f4d3d commit ecf719a

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{-# LANGUAGE NoFieldSelectors #-}
2+
3+
module NoFieldSelectorsExport (T (foo)) where
4+
5+
data T = MkT { foo :: T }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{-# LANGUAGE NoFieldSelectors #-}
2+
3+
module NoFieldSelectorsExport (T, foo) where
4+
5+
data T = MkT { foo :: T }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: Field selector exported with NoFieldSelectors
3+
---
4+
5+
## Error Message
6+
7+
```
8+
NoFieldSelectorsExport.hs:3:35: error: [GHC-76037]
9+
Not in scope: ‘foo’
10+
Suggested fix:
11+
Notice that ‘foo’ is a field selector belonging to the type ‘T’
12+
that has been suppressed by NoFieldSelectors.
13+
|
14+
3 | module NoFieldSelectorsExport (T, foo) where
15+
| ^^^
16+
```
17+
18+
## Explanation
19+
20+
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).

0 commit comments

Comments
 (0)