[Git][ghc/ghc][master] Fix non-symbolic children lookup of fixity decl

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Wed Oct 4 09:45:55 UTC 2023



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


Commits:
8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00
Fix non-symbolic children lookup of fixity decl

The fix for #23664 did not correctly account for non-symbolic names
when looking up children of a given parent. This one-line fix changes
that.

Fixes #24037

- - - - -


3 changed files:

- compiler/GHC/Types/Name/Reader.hs
- + testsuite/tests/rename/should_compile/T24037.hs
- testsuite/tests/rename/should_compile/all.T


Changes:

=====================================
compiler/GHC/Types/Name/Reader.hs
=====================================
@@ -1308,12 +1308,16 @@ childGREPriority (LookupChild { wantedParent = wanted_parent
         | isTermVarOrFieldNameSpace ns
         , isTermVarOrFieldNameSpace other_ns
         = Just 0
-        | ns == varName
+        | isValNameSpace varName
         , other_ns == tcName
-        -- When looking up children, we sometimes want to a symbolic variable
-        -- name to resolve to a type constructor, e.g. for an infix declaration
-        -- "infix +!" we want to take into account both class methods and associated
-        -- types. See test T10816.
+        -- When looking up children, we sometimes want a value name
+        -- to resolve to a type constructor.
+        -- For example, for an infix declaration "infixr 3 +!" or "infix 2 `Fun`"
+        -- inside a class declaration, we want to account for the possibility
+        -- that the identifier refers to an associated type (type constructor
+        -- NameSpace), when otherwise "+!" would be in the term-level variable
+        -- NameSpace, and "Fun" would be in the term-level data constructor
+        -- NameSpace.  See tests T10816, T23664, T24037.
         = Just 1
         | ns == tcName
         , other_ns == dataName


=====================================
testsuite/tests/rename/should_compile/T24037.hs
=====================================
@@ -0,0 +1,7 @@
+{-# LANGUAGE TypeFamilies, TypeOperators #-}
+
+module T24037 where
+
+class POrd a where
+  type Geq a b
+  infixr 6 `Geq`


=====================================
testsuite/tests/rename/should_compile/all.T
=====================================
@@ -215,6 +215,7 @@ test('T23434', normal, compile, [''])
 test('T23510b', normal, compile, [''])
 test('T23512b', normal, compile, [''])
 test('T23664', normal, compile, [''])
+test('T24037', normal, compile, [''])
 test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom'])
 test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom'])
 test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom'])



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8cee3fd7febdd97a9b4bcae7dddafe69b166149c
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/20231004/655195a3/attachment-0001.html>


More information about the ghc-commits mailing list