Skip to content

Commit 748769d

Browse files
committed
Fix resolution of qualified selectors in wildcards.
1 parent c73f60c commit 748769d

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

src/Language/Haskell/Names/Annotated.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ annotateRec _ sc a = go sc a where
5252
namesRes = do
5353
f <- sc ^. wcNames
5454
let localQName = qualifyName Nothing (setAnn (sLoc l) (wcFieldName f))
55-
selectorQName = qualifyName (Just (wcFieldModuleName f)) (wcFieldName f)
55+
symbol = wcFieldSymbol f
5656
Scoped info _ <- return (lookupQName localQName sc)
57-
Scoped (GlobalSymbol symbol _) _ <- return (lookupQName selectorQName (exprRS sc))
5857
return (symbol, info)
5958
_ -> rmap go sc a
6059
| Just (Refl :: PatField (Scoped l) :~: a) <- eqT
@@ -63,8 +62,7 @@ annotateRec _ sc a = go sc a where
6362
PFieldWildcard (Scoped (RecPatWildcard namesRes) (sLoc l)) where
6463
namesRes = do
6564
f <- sc ^. wcNames
66-
let qname = qualifyName (Just (wcFieldModuleName f)) (wcFieldName f)
67-
Scoped (GlobalSymbol symbol _) _ <- return (lookupQName qname (exprRS sc))
65+
let symbol = wcFieldSymbol f
6866
return symbol
6967
_ -> rmap go sc a
7068
| otherwise

src/Language/Haskell/Names/RecordWildcards.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ type WcNames = [WcField]
2626
data WcField = WcField
2727
{ wcFieldName :: Name ()
2828
-- ^ the field's simple name
29-
, wcFieldModuleName :: ModuleName ()
30-
-- ^ the field's original name
29+
, wcFieldSymbol :: Symbol
30+
-- ^ the field's selector symbol
3131
, wcExistsGlobalValue :: Bool
3232
-- ^ whether there is a global value in scope with the same name as
3333
-- the field but different from the field selector
@@ -76,7 +76,7 @@ getElidedFields globalTable con fields =
7676
let name = symbolName symbol
7777
wcfield = WcField
7878
{ wcFieldName = name
79-
, wcFieldModuleName = symbolModule symbol
79+
, wcFieldSymbol = symbol
8080
, wcExistsGlobalValue = existsGlobalValue name
8181
}
8282
return (name,wcfield))
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{-# LANGUAGE RecordWildCards #-}
2+
module WildcardsQualified where
3+
4+
import qualified Prelude as P (DataTypeWithSelectors(DataTypeWithSelectors,selector1))
5+
6+
u :: DataTypeWithSelectors -> ()
7+
u P.DataTypeWithSelectors{..} = let x = selector1 in ()
8+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
RecordWildCards at 1:14 is none
2+
DataTypeWithSelectors at 4:32 is import part for a global data type, Prelude.DataTypeWithSelectors
3+
DataTypeWithSelectors at 4:54 is a global constructor, Prelude.DataTypeWithSelectors
4+
selector1 at 4:76 is a global selector, Prelude.selector1
5+
u at 6:1 is a global value, WildcardsQualified.u
6+
DataTypeWithSelectors at 6:6 is not in scope
7+
DataTypeWithSelectors at 6:6 is not in scope
8+
() at 6:31 is none
9+
u at 7:1 is a value bound here
10+
DataTypeWithSelectors at 7:3 is a global constructor, Prelude.DataTypeWithSelectors
11+
DataTypeWithSelectors at 7:3 is a global constructor, Prelude.DataTypeWithSelectors
12+
.. at 7:27 is a record pattern wildcard which brings the following fields: Prelude.selector1
13+
x at 7:37 is a value bound here
14+
selector1 at 7:41 is a local value defined at 7:27
15+
selector1 at 7:41 is a local value defined at 7:27
16+
() at 7:54 is none

0 commit comments

Comments
 (0)