Vladislav Zavialov pushed to branch wip/int-index/iethingwith-subwc at Glasgow Haskell Compiler / GHC
Commits:
-
35031a58
by Vladislav Zavialov at 2026-05-15T23:24:37+03:00
25 changed files:
- compiler/GHC/Hs/ImpExp.hs
- compiler/GHC/Parser/Errors/Ppr.hs
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Parser/PostProcess/Haddock.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Tc/Gen/Export.hs
- compiler/Language/Haskell/Syntax/ImpExp.hs
- testsuite/tests/parser/should_compile/T14189.stderr
- + testsuite/tests/rename/should_compile/T25901_sub_w2_ok.hs
- testsuite/tests/rename/should_compile/all.T
- − testsuite/tests/rename/should_fail/T25901_sub_w.stderr
- testsuite/tests/rename/should_fail/T25901_sub_w.hs → testsuite/tests/rename/should_fail/T25901_sub_w0_fail.hs
- + testsuite/tests/rename/should_fail/T25901_sub_w0_fail.stderr
- + testsuite/tests/rename/should_fail/T25901_sub_w1.hs
- + testsuite/tests/rename/should_fail/T25901_sub_w1.stderr
- + testsuite/tests/rename/should_fail/T25901_sub_w1_helper.hs
- + testsuite/tests/rename/should_fail/T25901_sub_w2_fail.hs
- + testsuite/tests/rename/should_fail/T25901_sub_w2_fail.stderr
- testsuite/tests/rename/should_fail/all.T
- + testsuite/tests/warnings/should_compile/DodgyExports05.hs
- + testsuite/tests/warnings/should_compile/DodgyExports05.stderr
- + testsuite/tests/warnings/should_compile/DodgyImports05.hs
- + testsuite/tests/warnings/should_compile/DodgyImports05.stderr
- testsuite/tests/warnings/should_compile/all.T
- utils/check-exact/ExactPrint.hs
Changes:
| ... | ... | @@ -111,6 +111,14 @@ deriving instance Eq (NamespaceSpecifier GhcPs) |
| 111 | 111 | deriving instance Eq (NamespaceSpecifier GhcRn)
|
| 112 | 112 | deriving instance Eq (NamespaceSpecifier GhcTc)
|
| 113 | 113 | |
| 114 | +deriving instance Data (IEWildcard GhcPs)
|
|
| 115 | +deriving instance Data (IEWildcard GhcRn)
|
|
| 116 | +deriving instance Data (IEWildcard GhcTc)
|
|
| 117 | + |
|
| 118 | +deriving instance Eq (IEWildcard GhcPs)
|
|
| 119 | +deriving instance Eq (IEWildcard GhcRn)
|
|
| 120 | +deriving instance Eq (IEWildcard GhcTc)
|
|
| 121 | + |
|
| 114 | 122 | -- ---------------------------------------------------------------------
|
| 115 | 123 | |
| 116 | 124 | -- API Annotations types
|
| ... | ... | @@ -396,9 +404,9 @@ instance OutputableBndrId p => Outputable (IE (GhcPass p)) where |
| 396 | 404 | case wc of
|
| 397 | 405 | NoIEWildcard ->
|
| 398 | 406 | map (ppr . unLoc) withs
|
| 399 | - IEWildcard pos ->
|
|
| 407 | + IEWildcard pos ns_spec ->
|
|
| 400 | 408 | let (bs, as) = splitAt pos (map (ppr . unLoc) withs)
|
| 401 | - in bs ++ [text ".."] ++ as
|
|
| 409 | + in bs ++ [ppr ns_spec <+> text ".."] ++ as
|
|
| 402 | 410 | ppr ie@(IEModuleContents _ mod')
|
| 403 | 411 | = sep $ catMaybes [ppr <$> ieDeprecation ie, Just $ text "module" <+> ppr mod']
|
| 404 | 412 | ppr (IEWholeNamespace _ ns_spec) = ppr ns_spec <+> text ".."
|
| ... | ... | @@ -281,8 +281,8 @@ instance Diagnostic PsMessage where |
| 281 | 281 | [ text "Unsupported use of keyword" <+> quotes kw_doc
|
| 282 | 282 | , case pos of
|
| 283 | 283 | UnsupportedNameSpaceInIEThingWith ->
|
| 284 | - text "A namespace-specified wildcard may not appear alongside other items"
|
|
| 285 | - $$ text "in a list of children." ]
|
|
| 284 | + text "A namespace-specified wildcard may not appear alongside"
|
|
| 285 | + $$ text "other wildcards in a list of children." ]
|
|
| 286 | 286 | where
|
| 287 | 287 | kw_doc = case kw of
|
| 288 | 288 | ExplicitTypeNamespace{} -> text "type"
|
| ... | ... | @@ -174,7 +174,7 @@ import GHC.Utils.Panic |
| 174 | 174 | import qualified GHC.Data.Strict as Strict
|
| 175 | 175 | |
| 176 | 176 | import Control.Monad
|
| 177 | -import Text.ParserCombinators.ReadP as ReadP
|
|
| 177 | +import Text.ParserCombinators.ReadP as ReadP hiding (count)
|
|
| 178 | 178 | import Data.Char
|
| 179 | 179 | import Data.Data ( dataTypeOf, fromConstr, dataTypeConstrs )
|
| 180 | 180 | import Data.Kind ( Type )
|
| ... | ... | @@ -3325,14 +3325,17 @@ mkModuleImpExp ctx warning (top, tcp) (L l specname) subs = do |
| 3325 | 3325 | let withs = map unLoc xs
|
| 3326 | 3326 | pos = fromMaybe (panic "ImpExpAllWith with no wildcard") $ -- should've been ImpExpList
|
| 3327 | 3327 | findIndex isImpExpQcWildcard withs
|
| 3328 | - (m_kw,td,tc) = case withs !! pos of
|
|
| 3329 | - ImpExpQcWildcard m_kw td tc -> (m_kw,td,tc)
|
|
| 3328 | + m_kw = asum (map getImpExpQcWcKw withs)
|
|
| 3329 | + ns_spec = namespaceSpecifierFromKw m_kw
|
|
| 3330 | + (td,tc) = case withs !! pos of
|
|
| 3331 | + ImpExpQcWildcard _ td tc -> (td,tc)
|
|
| 3330 | 3332 | _ -> panic "mkModuleImpExp: item is not a wildcard" -- shouldn't have matched isImpExpQcWildcard
|
| 3331 | 3333 | ies :: [LocatedA (IEWrappedName GhcPs)]
|
| 3332 | 3334 | ies = wrapped $ filter (not . isImpExpQcWildcard . unLoc) xs
|
| 3333 | 3335 | newName <- nameT
|
| 3334 | 3336 | patSyns <- getBit PatternSynonymsBit
|
| 3335 | 3337 | if | Just kw <- m_kw ->
|
| 3338 | + unless (count isImpExpQcWildcard withs == 1) $
|
|
| 3336 | 3339 | unsupportedExplicitNamespaceKeyword kw UnsupportedNameSpaceInIEThingWith
|
| 3337 | 3340 | | InImportList <- ctx ->
|
| 3338 | 3341 | addFatalError $ mkPlainErrorMsgEnvelope (locA l) PsErrIllegalImportBundleForm
|
| ... | ... | @@ -3340,7 +3343,7 @@ mkModuleImpExp ctx warning (top, tcp) (L l specname) subs = do |
| 3340 | 3343 | addError $ mkPlainErrorMsgEnvelope (locA l) $ PsErrIllegalPatSynExport
|
| 3341 | 3344 | | otherwise -> return ()
|
| 3342 | 3345 | let x = IEThingWithExt warning top td tc tcp
|
| 3343 | - return $ IEThingWith x (L l newName) (IEWildcard pos) ies noExportDoc
|
|
| 3346 | + return $ IEThingWith x (L l newName) (IEWildcard pos ns_spec) ies noExportDoc
|
|
| 3344 | 3347 | where
|
| 3345 | 3348 | noExportDoc :: Maybe (LHsDoc GhcPs)
|
| 3346 | 3349 | noExportDoc = Nothing
|
| ... | ... | @@ -3459,6 +3462,10 @@ isImpExpQcWildcard :: ImpExpQcSpec -> Bool |
| 3459 | 3462 | isImpExpQcWildcard ImpExpQcWildcard{} = True
|
| 3460 | 3463 | isImpExpQcWildcard _ = False
|
| 3461 | 3464 | |
| 3465 | +getImpExpQcWcKw :: ImpExpQcSpec -> Maybe ExplicitNamespaceKeyword
|
|
| 3466 | +getImpExpQcWcKw (ImpExpQcWildcard m_kw _ _) = m_kw
|
|
| 3467 | +getImpExpQcWcKw _ = Nothing
|
|
| 3468 | + |
|
| 3462 | 3469 | -----------------------------------------------------------------------------
|
| 3463 | 3470 | -- Warnings and failures
|
| 3464 | 3471 |
| ... | ... | @@ -322,7 +322,7 @@ instance HasHaddock (LocatedA (IE GhcPs)) where |
| 322 | 322 | IEVar ext nm _ -> IEVar ext nm mb_ldoc
|
| 323 | 323 | IEThingAbs ext nm _ -> IEThingAbs ext nm mb_ldoc
|
| 324 | 324 | IEThingAll ext ns nm _ -> IEThingAll ext ns nm mb_ldoc
|
| 325 | - IEThingWith ext nm wild subs _ -> IEThingWith ext nm wild subs mb_ldoc
|
|
| 325 | + IEThingWith ext nm wc subs _ -> IEThingWith ext nm wc subs mb_ldoc
|
|
| 326 | 326 | x -> x
|
| 327 | 327 | pure $ L l_export ie'
|
| 328 | 328 |
| ... | ... | @@ -25,7 +25,8 @@ module GHC.Rename.Names ( |
| 25 | 25 | renamePkgQual, renameRawPkgQual,
|
| 26 | 26 | classifyGREs,
|
| 27 | 27 | ImportDeclUsage,
|
| 28 | - rnNamespaceSpecifier
|
|
| 28 | + rnNamespaceSpecifier,
|
|
| 29 | + rnIEWildcard
|
|
| 29 | 30 | ) where
|
| 30 | 31 | |
| 31 | 32 | import GHC.Prelude hiding ( head, init, last, tail )
|
| ... | ... | @@ -1182,6 +1183,10 @@ rnNamespaceSpecifier (NoNamespaceSpecifier _) = NoNamespaceSpecifier noExtFiel |
| 1182 | 1183 | rnNamespaceSpecifier (TypeNamespaceSpecifier x) = TypeNamespaceSpecifier x
|
| 1183 | 1184 | rnNamespaceSpecifier (DataNamespaceSpecifier x) = DataNamespaceSpecifier x
|
| 1184 | 1185 | |
| 1186 | +rnIEWildcard :: IEWildcard GhcPs -> IEWildcard GhcRn
|
|
| 1187 | +rnIEWildcard NoIEWildcard = NoIEWildcard
|
|
| 1188 | +rnIEWildcard (IEWildcard n ns_spec) = IEWildcard n (rnNamespaceSpecifier ns_spec)
|
|
| 1189 | + |
|
| 1185 | 1190 | filterImports
|
| 1186 | 1191 | :: HasDebugCallStack
|
| 1187 | 1192 | => HscEnv
|
| ... | ... | @@ -1379,13 +1384,30 @@ filterImports hsc_env iface decl_spec (Just (want_hiding, L l import_items)) |
| 1379 | 1384 | , maybeToList $ mk_depr_export_warning gre)
|
| 1380 | 1385 | |
| 1381 | 1386 | IEThingWith x ltc@(L l rdr_tc) wc rdr_ns _ -> do
|
| 1382 | - ImpOccItem { imp_item = gre, imp_bundled = subnames }
|
|
| 1387 | + ImpOccItem { imp_item = gre
|
|
| 1388 | + , imp_bundled = bundled_gres
|
|
| 1389 | + , imp_is_parent = is_par
|
|
| 1390 | + }
|
|
| 1383 | 1391 | <- lookup_parent (IEThingAbs Nothing ltc noDocstring) (ieWrappedName rdr_tc)
|
| 1384 | - let name = greName gre
|
|
| 1392 | + let name = greName gre
|
|
| 1393 | + ns_spec = case wc of
|
|
| 1394 | + NoIEWildcard -> NoNamespaceSpecifier noExtField
|
|
| 1395 | + IEWildcard _ n -> n
|
|
| 1396 | + has_wc = case wc of
|
|
| 1397 | + NoIEWildcard -> False
|
|
| 1398 | + IEWildcard{} -> True
|
|
| 1399 | + |
|
| 1400 | + child_gres, wc_gres :: [GlobalRdrElt]
|
|
| 1401 | + child_gres
|
|
| 1402 | + | is_par = filterByNamespaceSpecifierGREs ns_spec bundled_gres
|
|
| 1403 | + | otherwise = []
|
|
| 1404 | + wc_gres
|
|
| 1405 | + | has_wc = child_gres
|
|
| 1406 | + | otherwise = []
|
|
| 1385 | 1407 | |
| 1386 | 1408 | -- Look up the children in the sub-names of the parent
|
| 1387 | 1409 | -- See Note [Importing DuplicateRecordFields]
|
| 1388 | - let (children_errs, childnames) = lookupChildren subnames rdr_ns
|
|
| 1410 | + let (children_errs, childnames) = lookupChildren bundled_gres rdr_ns
|
|
| 1389 | 1411 | |
| 1390 | 1412 | bad_import_warns <-
|
| 1391 | 1413 | if null children_errs then return [] else
|
| ... | ... | @@ -1400,17 +1422,22 @@ filterImports hsc_env iface decl_spec (Just (want_hiding, L l import_items)) |
| 1400 | 1422 | |
| 1401 | 1423 | let name' = replaceWrappedName rdr_tc name
|
| 1402 | 1424 | childnames' = map (to_ie_post_rn . fmap greName) childnames
|
| 1403 | - gres = gre : map unLoc childnames
|
|
| 1425 | + explicit_gres = gre : map unLoc childnames
|
|
| 1426 | + imp_list_wc_warn
|
|
| 1427 | + | not has_wc = []
|
|
| 1428 | + | null child_gres = [DodgyImport (DodgyImportsEmptyParent ie ns_spec gre)]
|
|
| 1429 | + | not (is_qual decl_spec) = [MissingImportList]
|
|
| 1430 | + | otherwise = []
|
|
| 1404 | 1431 | export_depr_warns
|
| 1405 | - | want_hiding == Exactly = mapMaybe mk_depr_export_warning gres
|
|
| 1432 | + | want_hiding == Exactly = mapMaybe mk_depr_export_warning explicit_gres
|
|
| 1406 | 1433 | | otherwise = []
|
| 1407 | 1434 | renamed_ie = IEThingWith (x { ietw_warning = Nothing })
|
| 1408 | 1435 | (L l name')
|
| 1409 | - wc
|
|
| 1436 | + (rnIEWildcard wc)
|
|
| 1410 | 1437 | childnames'
|
| 1411 | 1438 | noDocstring
|
| 1412 | - return ( [(renamed_ie, gres)]
|
|
| 1413 | - , bad_import_warns ++ export_depr_warns)
|
|
| 1439 | + return ( [(renamed_ie, explicit_gres ++ wc_gres)]
|
|
| 1440 | + , bad_import_warns ++ imp_list_wc_warn ++ export_depr_warns)
|
|
| 1414 | 1441 | |
| 1415 | 1442 | IEWholeNamespace x ns_spec -> do
|
| 1416 | 1443 | let mod_name = moduleName import_mod
|
| ... | ... | @@ -2017,8 +2044,8 @@ findImportUsage imports used_gres |
| 2017 | 2044 | where pn = lieWrappedName p
|
| 2018 | 2045 | xs = map lieWrappedName ns
|
| 2019 | 2046 | add_wc_all = case wc of
|
| 2020 | - NoIEWildcard -> id
|
|
| 2021 | - IEWildcard _ -> add_unused_all pn
|
|
| 2047 | + NoIEWildcard -> id
|
|
| 2048 | + IEWildcard _ _ns_spec -> add_unused_all pn
|
|
| 2022 | 2049 | add_unused (IEWholeNamespace x ns_spec) acc = add_unused_wildcard ns_spec (iewn_names x) acc
|
| 2023 | 2050 | add_unused _ acc = acc
|
| 2024 | 2051 |
| ... | ... | @@ -648,8 +648,8 @@ exports_from_avail (Just (L _ rdr_items)) rdr_env imports this_mod |
| 648 | 648 | |
| 649 | 649 | wc_kids <-
|
| 650 | 650 | case wc of
|
| 651 | - NoIEWildcard -> return []
|
|
| 652 | - IEWildcard _ -> lookup_ie_kids_all ie (NoNamespaceSpecifier noExtField) l par
|
|
| 651 | + NoIEWildcard -> return []
|
|
| 652 | + IEWildcard _ ns_spec -> lookup_ie_kids_all ie ns_spec l par
|
|
| 653 | 653 | |
| 654 | 654 | let name = greName par
|
| 655 | 655 | all_kids = with_kids ++ wc_kids
|
| ... | ... | @@ -670,7 +670,10 @@ exports_from_avail (Just (L _ rdr_items)) rdr_env imports this_mod |
| 670 | 670 | return ( expacc{ expacc_exp_occs = occs'
|
| 671 | 671 | , expacc_warn_spans = export_warn_spans'
|
| 672 | 672 | , expacc_dont_warn = dont_warn_export' }
|
| 673 | - , L loc (IEThingWith x' (replaceLWrappedName l name) wc subs doc')
|
|
| 673 | + , L loc (IEThingWith x' (replaceLWrappedName l name)
|
|
| 674 | + (rnIEWildcard wc)
|
|
| 675 | + subs
|
|
| 676 | + doc')
|
|
| 674 | 677 | , Just $ AvailTC name all_names )
|
| 675 | 678 | |
| 676 | 679 | lookup_ie _ _ = panic "lookup_ie" -- Other cases covered earlier
|
| ... | ... | @@ -110,7 +110,7 @@ data IE pass |
| 110 | 110 | -- See Note [Located RdrNames] in GHC.Hs.Expr
|
| 111 | 111 | | IEThingWith (XIEThingWith pass)
|
| 112 | 112 | (LIEWrappedName pass)
|
| 113 | - IEWildcard
|
|
| 113 | + (IEWildcard pass)
|
|
| 114 | 114 | [LIEWrappedName pass]
|
| 115 | 115 | (Maybe (ExportDoc pass))
|
| 116 | 116 | -- ^ Imported or exported thing with explicit subordinate list.
|
| ... | ... | @@ -166,13 +166,14 @@ data IE pass |
| 166 | 166 | | XIE !(XXIE pass)
|
| 167 | 167 | |
| 168 | 168 | -- | Wildcard in an import or export sublist, like the @..@ in
|
| 169 | --- @import Mod ( T(Mk1, Mk2, ..) )@.
|
|
| 170 | -data IEWildcard
|
|
| 169 | +-- @import Mod ( T(Mk1, Mk2, ..) )@ or @import Mod ( T(Mk1, type ..) )@.
|
|
| 170 | +data IEWildcard pass
|
|
| 171 | 171 | = NoIEWildcard -- ^ no wildcard in this list
|
| 172 | - | IEWildcard Int -- ^ wildcard after the given \# of items in this list
|
|
| 172 | + | IEWildcard Int (NamespaceSpecifier pass)
|
|
| 173 | + -- ^ wildcard after the given \# of items in this list,
|
|
| 174 | + -- with an optional namespace specifier
|
|
| 173 | 175 | -- The @Int@ is in the range [0..n], where n is the length
|
| 174 | 176 | -- of the list.
|
| 175 | - deriving (Eq, Data)
|
|
| 176 | 177 | |
| 177 | 178 | -- | A name in an import or export specification which may have
|
| 178 | 179 | -- adornments. Used primarily for accurate pretty printing of
|
| ... | ... | @@ -303,15 +303,14 @@ |
| 303 | 303 | (EpaComments
|
| 304 | 304 | []))
|
| 305 | 305 | (IEThingWith
|
| 306 | - ((,)
|
|
| 306 | + (IEThingWithExt
|
|
| 307 | 307 | (Nothing)
|
| 308 | - ((,,,)
|
|
| 309 | - (EpTok
|
|
| 310 | - (EpaSpan { T14189.hs:3:10 }))
|
|
| 311 | - (NoEpTok)
|
|
| 312 | - (NoEpTok)
|
|
| 313 | - (EpTok
|
|
| 314 | - (EpaSpan { T14189.hs:3:15 }))))
|
|
| 308 | + (EpTok
|
|
| 309 | + (EpaSpan { T14189.hs:3:10 }))
|
|
| 310 | + (NoEpTok)
|
|
| 311 | + (NoEpTok)
|
|
| 312 | + (EpTok
|
|
| 313 | + (EpaSpan { T14189.hs:3:15 })))
|
|
| 315 | 314 | (L
|
| 316 | 315 | (EpAnn
|
| 317 | 316 | (EpaSpan { T14189.hs:3:3-8 })
|
| 1 | +{-# LANGUAGE NoImplicitPrelude #-}
|
|
| 2 | +{-# LANGUAGE ExplicitNamespaces #-}
|
|
| 3 | + |
|
| 4 | +module T25901_sub_w2_ok where
|
|
| 5 | + |
|
| 6 | +import Data.Bool (Bool(False, data ..))
|
|
| 7 | + |
|
| 8 | +true :: Bool
|
|
| 9 | +true = True -- ok: imported via subordinate wildcard `data ..`
|
|
| 10 | + |
|
| 11 | +false :: Bool
|
|
| 12 | +false = False -- ok: imported via explicit subordinate item `False` |
| ... | ... | @@ -256,3 +256,4 @@ test('T25901_exp_2', [extra_files(['T25901_exp_2_helper.hs'])], multimod_compile |
| 256 | 256 | test('T25901_sub_e', normal, compile, [''])
|
| 257 | 257 | test('T25901_sub_f', normal, compile, ['-Wdodgy-exports -Wno-duplicate-exports'])
|
| 258 | 258 | test('T25901_sub_g', [extra_files(['T25901_sub_g_helper.hs'])], multimod_compile, ['T25901_sub_g', '-v0 -Wdodgy-imports'])
|
| 259 | +test('T25901_sub_w2_ok', normal, compile, ['']) |
| 1 | -T25901_sub_w.hs:3:29: error: [GHC-04611]
|
|
| 2 | - • Unsupported use of keyword ‘data’
|
|
| 3 | - • A namespace-specified wildcard may not appear alongside other items
|
|
| 4 | - in a list of children.
|
|
| 5 | - |
|
| 6 | -T25901_sub_w.hs:5:31: error: [GHC-04611]
|
|
| 7 | - • Unsupported use of keyword ‘data’
|
|
| 8 | - • A namespace-specified wildcard may not appear alongside other items
|
|
| 9 | - in a list of children.
|
|
| 10 | - |
|
| 11 | -T25901_sub_w.hs:6:25: error: [GHC-04611]
|
|
| 12 | - • Unsupported use of keyword ‘type’
|
|
| 13 | - • A namespace-specified wildcard may not appear alongside other items
|
|
| 14 | - in a list of children.
|
|
| 15 | - |
| 1 | 1 | {-# LANGUAGE ExplicitNamespaces #-}
|
| 2 | 2 | |
| 3 | -module T25901_sub_w (T(MkT, data ..)) where
|
|
| 3 | +module T25901_sub_w0_fail (T(.., data ..)) where
|
|
| 4 | 4 | |
| 5 | -import Data.Bool (Bool(False, data ..))
|
|
| 6 | 5 | import GHC.Exts (IsList(type .., data ..))
|
| 7 | 6 | |
| 8 | 7 | data T = MkT |
| 1 | +T25901_sub_w0_fail.hs:3:34: error: [GHC-04611]
|
|
| 2 | + • Unsupported use of keyword ‘data’
|
|
| 3 | + • A namespace-specified wildcard may not appear alongside
|
|
| 4 | + other wildcards in a list of children.
|
|
| 5 | + |
|
| 6 | +T25901_sub_w0_fail.hs:5:25: error: [GHC-04611]
|
|
| 7 | + • Unsupported use of keyword ‘type’
|
|
| 8 | + • A namespace-specified wildcard may not appear alongside
|
|
| 9 | + other wildcards in a list of children.
|
|
| 10 | + |
| 1 | +{-# LANGUAGE TemplateHaskell #-}
|
|
| 2 | + |
|
| 3 | +module T25901_sub_w1 where
|
|
| 4 | + |
|
| 5 | +import Data.Kind (Type)
|
|
| 6 | +import T25901_sub_w1_helper
|
|
| 7 | + |
|
| 8 | +-- This is OK
|
|
| 9 | +type F' :: Type -> Type -> Type
|
|
| 10 | +type F' a b = F a b
|
|
| 11 | + |
|
| 12 | +-- This is OK
|
|
| 13 | +f', g', (#.) :: C a b => a -> b -> ()
|
|
| 14 | +f' = f
|
|
| 15 | +g' = g
|
|
| 16 | +(#.) = (#)
|
|
| 17 | + |
|
| 18 | +$(return []) -- ensure we check the term-level definitions above
|
|
| 19 | + |
|
| 20 | +-- This should fail because 'G' is not exported by T25901_sub_w1_helper
|
|
| 21 | +type G' :: Type -> Type -> Type
|
|
| 22 | +type G' a b = G a b
|
|
| 23 | + |
|
| 24 | +-- This should fail because (#) in the type namespace is not exported by T25901_sub_w1_helper
|
|
| 25 | +type (#.) :: Type -> Type -> Type
|
|
| 26 | +type a #. b = a # b |
| 1 | +T25901_sub_w1.hs:22:15: error: [GHC-76037]
|
|
| 2 | + Not in scope: type constructor or class ‘G’
|
|
| 3 | + |
|
| 4 | +T25901_sub_w1.hs:26:17: error: [GHC-76037]
|
|
| 5 | + Not in scope: type constructor or class ‘#’
|
|
| 6 | + |
| 1 | +{-# LANGUAGE ExplicitNamespaces, TypeFamilies #-}
|
|
| 2 | + |
|
| 3 | +-- Exported:
|
|
| 4 | +-- * class 'C'
|
|
| 5 | +-- * term operator (#)
|
|
| 6 | +-- * methods 'f' and 'g'
|
|
| 7 | +-- * associated type 'F'
|
|
| 8 | +-- Not exported:
|
|
| 9 | +-- * type operator (#)
|
|
| 10 | +-- * associated type 'G'
|
|
| 11 | +module T25901_sub_w1_helper (C(data .., F)) where
|
|
| 12 | + |
|
| 13 | +class C a b where
|
|
| 14 | + type F a b
|
|
| 15 | + type G a b
|
|
| 16 | + type a # b
|
|
| 17 | + f, g, (#) :: a -> b -> () |
|
| \ No newline at end of file |
| 1 | +{-# LANGUAGE NoImplicitPrelude #-}
|
|
| 2 | +{-# LANGUAGE ExplicitNamespaces #-}
|
|
| 3 | + |
|
| 4 | +module T25901_sub_w2_fail where
|
|
| 5 | + |
|
| 6 | +import Data.Bool (Bool(False, type ..))
|
|
| 7 | + |
|
| 8 | +true :: Bool
|
|
| 9 | +true = True -- error: /not/ imported via subordinate wildcard `type ..`
|
|
| 10 | + |
|
| 11 | +false :: Bool
|
|
| 12 | +false = False -- ok: imported via explicit subordinate item `False` |
| 1 | +T25901_sub_w2_fail.hs:9:8: error: [GHC-88464]
|
|
| 2 | + Data constructor not in scope: True :: Bool
|
|
| 3 | + Suggested fixes:
|
|
| 4 | + • Perhaps use variable ‘true’ (line 9)
|
|
| 5 | + • Add ‘True’ to the import list in the import of ‘Data.Bool’
|
|
| 6 | + (at T25901_sub_w2_fail.hs:6:1-39).
|
|
| 7 | + |
| ... | ... | @@ -262,5 +262,7 @@ test('T25901_sub_a', normal, compile_fail, ['']) |
| 262 | 262 | test('T25901_sub_b', normal, compile_fail, [''])
|
| 263 | 263 | test('T25901_sub_c', [extra_files(['T25901_sub_c_helper.hs'])], multimod_compile_fail, ['T25901_sub_c', '-v0'])
|
| 264 | 264 | test('T25901_sub_d', [extra_files(['T25901_sub_d_helper.hs'])], multimod_compile_fail, ['T25901_sub_d', '-v0'])
|
| 265 | -test('T25901_sub_w', normal, compile_fail, [''])
|
|
| 265 | +test('T25901_sub_w0_fail', normal, compile_fail, [''])
|
|
| 266 | +test('T25901_sub_w2_fail', normal, compile_fail, [''])
|
|
| 267 | +test('T25901_sub_w1', [extra_files(['T25901_sub_w1_helper.hs'])], multimod_compile_fail, ['T25901_sub_w1', '-v0'])
|
|
| 266 | 268 | test('T26545', normal, compile_fail, ['']) |
| 1 | +{-# LANGUAGE ExplicitNamespaces #-}
|
|
| 2 | + |
|
| 3 | +module DodgyExports05
|
|
| 4 | + ( Bool(False, type ..)
|
|
| 5 | + ) where |
|
| \ No newline at end of file |
| 1 | +DodgyExports05.hs:4:5: warning: [GHC-75356] [-Wdodgy-exports (in -Wextra)]
|
|
| 2 | + The export item ‘Bool(False, type ..)’ suggests that
|
|
| 3 | + ‘Bool’ has associated types,
|
|
| 4 | + but it is not a class
|
|
| 5 | + |
| 1 | +{-# LANGUAGE NoImplicitPrelude #-}
|
|
| 2 | +{-# LANGUAGE ExplicitNamespaces #-}
|
|
| 3 | + |
|
| 4 | +module DodgyImports05 where
|
|
| 5 | + |
|
| 6 | +import Data.Bool (Bool(False, type ..)) |
|
| \ No newline at end of file |
| 1 | +DodgyImports05.hs:6:19: warning: [GHC-99623] [-Wdodgy-imports (in -Wextra)]
|
|
| 2 | + The import item ‘Bool(False, type ..)’ suggests that
|
|
| 3 | + ‘GHC.Internal.Types.Bool’ has associated types,
|
|
| 4 | + but it is not a class
|
|
| 5 | + |
| ... | ... | @@ -56,6 +56,7 @@ test('T19296', normal, compile, ['-fdiagnostics-show-caret -Wredundant-constrain |
| 56 | 56 | test('DodgyExports01', normal, compile, ['-Wdodgy-exports'])
|
| 57 | 57 | test('DodgyExports02', normal, compile, ['-Wdodgy-exports'])
|
| 58 | 58 | test('DodgyExports03', normal, compile, ['-Wdodgy-exports'])
|
| 59 | +test('DodgyExports05', normal, compile, ['-Wdodgy-exports'])
|
|
| 59 | 60 | test('T25901_exp_dodgy', normal, compile, ['-Wdodgy-exports'])
|
| 60 | 61 | test('T25901_exp_dup_wc_1', normal, compile, ['-Wduplicate-exports'])
|
| 61 | 62 | test('T25901_exp_dup_wc_2', normal, compile, ['-Wduplicate-exports'])
|
| ... | ... | @@ -74,6 +75,7 @@ test('DodgyImports_hiding', normal, compile, ['-Wdodgy-imports']) |
| 74 | 75 | test('DodgyImports02', normal, compile, ['-Wdodgy-imports'])
|
| 75 | 76 | test('DodgyImports03', [extra_files(["DodgyImports03_helper.hs"])], multimod_compile, ['DodgyImports03', '-Wdodgy-imports -v0'])
|
| 76 | 77 | test('DodgyImports04', normal, compile, ['-Wdodgy-imports'])
|
| 78 | +test('DodgyImports05', normal, compile, ['-Wdodgy-imports'])
|
|
| 77 | 79 | test('T22702a', normal, compile, [''])
|
| 78 | 80 | test('T22702b', normal, compile, [''])
|
| 79 | 81 | test('T22826', normal, compile, [''])
|
| ... | ... | @@ -4594,18 +4594,19 @@ instance ExactPrint (IE GhcPs) where |
| 4594 | 4594 | depr' <- markAnnotated (ietw_warning x)
|
| 4595 | 4595 | thing' <- markAnnotated thing
|
| 4596 | 4596 | op' <- markEpToken (ietw_tok_lpar x)
|
| 4597 | - (dd',c', wc', withs') <-
|
|
| 4597 | + (dd', c', wc', withs') <-
|
|
| 4598 | 4598 | case wc of
|
| 4599 | 4599 | NoIEWildcard -> do
|
| 4600 | 4600 | withs'' <- markAnnotated withs
|
| 4601 | 4601 | return (ietw_tok_wc x, ietw_tok_comma x, wc, withs'')
|
| 4602 | - IEWildcard pos -> do
|
|
| 4602 | + IEWildcard pos ns_spec -> do
|
|
| 4603 | 4603 | let (bs, as) = splitAt pos withs
|
| 4604 | 4604 | bs' <- markAnnotated bs
|
| 4605 | + ns_spec' <- markAnnotated ns_spec
|
|
| 4605 | 4606 | dd' <- markEpToken (ietw_tok_wc x)
|
| 4606 | 4607 | c' <- markEpToken (ietw_tok_comma x)
|
| 4607 | 4608 | as' <- markAnnotated as
|
| 4608 | - return (dd',c', wc, bs'++as')
|
|
| 4609 | + return (dd', c', IEWildcard pos ns_spec', bs'++as')
|
|
| 4609 | 4610 | cp' <- markEpToken (ietw_tok_rpar x)
|
| 4610 | 4611 | doc' <- markAnnotated doc
|
| 4611 | 4612 | let x' = IEThingWithExt depr' op' dd' c' cp'
|