[Git][ghc/ghc][master] No shadowing warnings for NoFieldSelector fields

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Mon Jan 29 22:27:36 UTC 2024



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
ced2e731 by sheaf at 2024-01-29T17:27:12-05:00
No shadowing warnings for NoFieldSelector fields

This commit ensures we don't emit shadowing warnings when a user
shadows a field defined with NoFieldSelectors.

Fixes #24381

- - - - -


3 changed files:

- compiler/GHC/Rename/Utils.hs
- + testsuite/tests/overloadedrecflds/should_compile/T24381.hs
- testsuite/tests/overloadedrecflds/should_compile/all.T


Changes:

=====================================
compiler/GHC/Rename/Utils.hs
=====================================
@@ -182,7 +182,7 @@ checkShadowedOccs (global_env,local_env) get_loc_occ ns
         where
           (loc,occ) = get_loc_occ n
           mb_local  = lookupLocalRdrOcc local_env occ
-          gres      = lookupGRE global_env (LookupRdrName (mkRdrUnqual occ) (RelevantGREsFOS WantBoth))
+          gres      = lookupGRE global_env (LookupRdrName (mkRdrUnqual occ) (RelevantGREsFOS WantNormal))
                 -- Make an Unqualified RdrName and look that up, so that
                 -- we don't find any GREs that are in scope qualified-only
 


=====================================
testsuite/tests/overloadedrecflds/should_compile/T24381.hs
=====================================
@@ -0,0 +1,6 @@
+{-# OPTIONS_GHC -Wname-shadowing #-}
+{-# LANGUAGE Haskell2010 #-} -- Necessary to avoid `NamedFieldPuns` from `GHC2021`.
+{-# LANGUAGE NoFieldSelectors #-}
+module M where
+data T = C { x :: () }
+f x = x


=====================================
testsuite/tests/overloadedrecflds/should_compile/all.T
=====================================
@@ -60,3 +60,4 @@ test('T23557', [extra_files(['T23557_aux.hs'])], multimod_compile, ['T23557', '-
 test('T24293', req_th, compile, [''])
 test('T24293b', req_th, compile, [''])
 test('T24293c', req_th, compile_fail, [''])
+test('T24381', normal, compile, [''])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ced2e7312b692e3f5402e4db6cfec390653a6a06

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ced2e7312b692e3f5402e4db6cfec390653a6a06
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240129/e1a5c16a/attachment-0001.html>


More information about the ghc-commits mailing list