summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAdam Gundry <adam@well-typed.com>2022-08-17 20:49:24 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-09-13 10:28:29 -0400
commit08f6730cd04ae9cdba30c0e371522ddc9a25b716 (patch)
treee5d4402edeb411866293b834b045b78211c9a61b /docs
parent362cca13858faf7e1158273780ea900e7dad5827 (diff)
downloadhaskell-08f6730cd04ae9cdba30c0e371522ddc9a25b716.tar.gz
Allow imports to reference multiple fields with the same name (#21625)
If a module `M` exports two fields `f` (using DuplicateRecordFields), we can still accept import M (f) import M hiding (f) and treat `f` as referencing both of them. This was accepted in GHC 9.0, but gave rise to an ambiguity error in GHC 9.2. See #21625. This patch also documents this behaviour in the user's guide, and updates the test for #16745 which is now treated differently.
Diffstat (limited to 'docs')
-rw-r--r--docs/users_guide/exts/duplicate_record_fields.rst9
1 files changed, 8 insertions, 1 deletions
diff --git a/docs/users_guide/exts/duplicate_record_fields.rst b/docs/users_guide/exts/duplicate_record_fields.rst
index aa842e7b4f..0a7504c399 100644
--- a/docs/users_guide/exts/duplicate_record_fields.rst
+++ b/docs/users_guide/exts/duplicate_record_fields.rst
@@ -57,4 +57,11 @@ However, this would not be permitted, because ``x`` is ambiguous: ::
module M (x) where ...
-The same restrictions apply on imports.
+For ``import`` statements, it is possible to import multiple fields with the
+same name, as well as importing individual fields as part of their datatypes.
+For example, the following imports are allowed: ::
+
+ import M (S(x)) -- imports the type S and the 'x' field of S (but not the field of T)
+ import M (x) -- imports both 'x' fields
+ import M hiding (S(x)) -- imports everything except the type S and its 'x' field
+ import M hiding (x) -- imports everything except the two 'x' fields