Skip to content

Commit c73f60c

Browse files
committed
Make sure that symbols exported by export wildcards in fact belong to
that type or class.
1 parent 0c4e92c commit c73f60c

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

src/Language/Haskell/Names/Exports.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ annotateExportSpec globalTable exportSpec =
7272
let
7373
subSymbols = nub (do
7474
subSymbol <- concat (Map.elems globalTable)
75-
Just n' <- return $ symbolParent subSymbol
76-
guard (n' == symbolName symbol)
75+
Just subSymbolParentName <- return $ symbolParent subSymbol
76+
guard (subSymbolParentName == symbolName symbol)
77+
guard (symbolModule subSymbol == symbolModule symbol)
7778
return subSymbol)
7879
s = [symbol] <> subSymbols
7980
in

tests/exports/ExportAmbiguous.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module ExportAmbiguous (DataType(..)) where
2+
3+
import qualified Prelude (DataType(..))
4+
import Prelude hiding (DataType(..))
5+
6+
data DataType = Constructor1 | Constructor2
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[ Data
2+
{ symbolModule = ModuleName () "ExportAmbiguous"
3+
, symbolName = Ident () "DataType"
4+
}
5+
, Constructor
6+
{ symbolModule = ModuleName () "ExportAmbiguous"
7+
, symbolName = Ident () "Constructor1"
8+
, typeName = Ident () "DataType"
9+
}
10+
, Constructor
11+
{ symbolModule = ModuleName () "ExportAmbiguous"
12+
, symbolName = Ident () "Constructor2"
13+
, typeName = Ident () "DataType"
14+
}
15+
]

0 commit comments

Comments
 (0)