Skip to content

Commit

Permalink
Add NoFieldSelectors example to GHC-76037
Browse files Browse the repository at this point in the history
  • Loading branch information
tbidne authored and BinderDavid committed Feb 25, 2024
1 parent 35f4d3d commit ecf719a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
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 }
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 }
20 changes: 20 additions & 0 deletions message-index/messages/GHC-76037/example4/index.md
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).

0 comments on commit ecf719a

Please sign in to comment.