From ecf719a0b8dc398f23820e82c6c02e450e751eda Mon Sep 17 00:00:00 2001 From: Tommy Bidne Date: Sat, 24 Feb 2024 12:22:07 +1300 Subject: [PATCH] Add NoFieldSelectors example to GHC-76037 --- .../example4/after/NoFieldSelectorsExport.hs | 5 +++++ .../example4/before/NoFieldSelectorsExport.hs | 5 +++++ .../messages/GHC-76037/example4/index.md | 20 +++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 message-index/messages/GHC-76037/example4/after/NoFieldSelectorsExport.hs create mode 100644 message-index/messages/GHC-76037/example4/before/NoFieldSelectorsExport.hs create mode 100644 message-index/messages/GHC-76037/example4/index.md diff --git a/message-index/messages/GHC-76037/example4/after/NoFieldSelectorsExport.hs b/message-index/messages/GHC-76037/example4/after/NoFieldSelectorsExport.hs new file mode 100644 index 00000000..1e3c37f8 --- /dev/null +++ b/message-index/messages/GHC-76037/example4/after/NoFieldSelectorsExport.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE NoFieldSelectors #-} + +module NoFieldSelectorsExport (T (foo)) where + +data T = MkT { foo :: T } diff --git a/message-index/messages/GHC-76037/example4/before/NoFieldSelectorsExport.hs b/message-index/messages/GHC-76037/example4/before/NoFieldSelectorsExport.hs new file mode 100644 index 00000000..7f81964e --- /dev/null +++ b/message-index/messages/GHC-76037/example4/before/NoFieldSelectorsExport.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE NoFieldSelectors #-} + +module NoFieldSelectorsExport (T, foo) where + +data T = MkT { foo :: T } diff --git a/message-index/messages/GHC-76037/example4/index.md b/message-index/messages/GHC-76037/example4/index.md new file mode 100644 index 00000000..30853f0e --- /dev/null +++ b/message-index/messages/GHC-76037/example4/index.md @@ -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).