[Git][ghc/ghc][wip/amg/fieldselectors] 3 commits: Exclude NoFieldSelectors GREs from similarNameSuggestions

Adam Gundry gitlab at gitlab.haskell.org
Tue Nov 24 22:28:43 UTC 2020



Adam Gundry pushed to branch wip/amg/fieldselectors at Glasgow Haskell Compiler / GHC


Commits:
4dea2af5 by Adam Gundry at 2020-11-24T22:08:06+00:00
Exclude NoFieldSelectors GREs from similarNameSuggestions

- - - - -
8904a2a7 by Adam Gundry at 2020-11-24T22:25:15+00:00
Hackily correct for T11941

- - - - -
461c9ba8 by Adam Gundry at 2020-11-24T22:28:35+00:00
Minor diff cleanup

- - - - -


4 changed files:

- compiler/GHC/Rename/Pat.hs
- compiler/GHC/Rename/Unbound.hs
- testsuite/tests/th/T11941.stderr
- testsuite/tests/typecheck/should_compile/all.T


Changes:

=====================================
compiler/GHC/Rename/Pat.hs
=====================================
@@ -751,13 +751,16 @@ rnHsRecUpdFields flds
            ; sel <- setSrcSpan loc $
                       -- Defer renaming of overloaded fields to the typechecker
                       -- See Note [Disambiguating record fields] in GHC.Tc.Gen.Head
-                      do  { mb <- lookupGlobalOccRn_overloaded_sel overload_ok lbl
-                          ; case mb of
-                              Nothing ->
-                                do { addErr
-                                        (unknownSubordinateErr doc lbl)
-                                    ; return Nothing }
-                              Just r -> return $ Just r }
+                      -- AMG TODO: not clear why we need this test, but T11941 fails if we don't
+                      if overload_ok == DuplicateRecordFields
+                          then do  { mb <- lookupGlobalOccRn_overloaded_sel overload_ok lbl
+                                   ; case mb of
+                                       Nothing ->
+                                         do { addErr
+                                              (unknownSubordinateErr doc lbl)
+                                            ; return Nothing }
+                                       Just r -> return $ Just r }
+                          else fmap (Just . LookupOccRnUnique) $ lookupGlobalOccRn lbl
            ; arg' <- if pun
                      then do { checkErr pun_ok (badPun (L loc lbl))
                                -- Discard any module qualifier (#11662)


=====================================
compiler/GHC/Rename/Unbound.hs
=====================================
@@ -193,6 +193,7 @@ similarNameSuggestions where_look dflags global_env
       | tried_is_qual = [ (rdr_qual, (rdr_qual, how))
                         | gre <- globalRdrEnvElts global_env
                         , isGreOk where_look gre
+                        , not (isNoFieldSelectorGRE gre)
                         , let occ = greOccName gre
                         , correct_name_space occ
                         , (mod, how) <- qualsInScope gre
@@ -201,6 +202,7 @@ similarNameSuggestions where_look dflags global_env
       | otherwise = [ (rdr_unqual, pair)
                     | gre <- globalRdrEnvElts global_env
                     , isGreOk where_look gre
+                    , not (isNoFieldSelectorGRE gre)
                     , let occ = greOccName gre
                           rdr_unqual = mkRdrUnqual occ
                     , correct_name_space occ


=====================================
testsuite/tests/th/T11941.stderr
=====================================
@@ -1,3 +1,6 @@
 
 T11941.hs:7:30: error:
-    ‘getFrst’ is not a (visible) constructor field name
\ No newline at end of file
+    Not in scope: ‘getFrst’
+    Perhaps you meant one of these:
+      ‘getFirst’ (imported from Data.Monoid),
+      ‘getLast’ (imported from Data.Monoid)


=====================================
testsuite/tests/typecheck/should_compile/all.T
=====================================
@@ -728,3 +728,4 @@ test('T18831', normal, compile, [''])
 test('T18920', normal, compile, [''])
 test('T15942', normal, compile, [''])
 test('ClassDefaultInHsBoot', [extra_files(['ClassDefaultInHsBootA1.hs','ClassDefaultInHsBootA2.hs','ClassDefaultInHsBootA2.hs-boot','ClassDefaultInHsBootA3.hs'])], multimod_compile, ['ClassDefaultInHsBoot', '-v0'])
+



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/59a0c52a763690a5ac94e3ff4a2e1525cb5fa293...461c9ba829fd4090d7aa11366cc908f1b6a42cb3

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/59a0c52a763690a5ac94e3ff4a2e1525cb5fa293...461c9ba829fd4090d7aa11366cc908f1b6a42cb3
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/20201124/9463dd9a/attachment-0001.html>


More information about the ghc-commits mailing list