[Git][ghc/ghc][master] Modified the default export implementation to match the amended spec
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Wed Sep 18 11:56:38 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
9d20a787 by Mario Blažević at 2024-09-18T07:56:08-04:00
Modified the default export implementation to match the amended spec
- - - - -
5 changed files:
- compiler/GHC/Tc/Gen/Export.hs
- − testsuite/tests/default/DefaultImport04.stdout
- testsuite/tests/default/DefaultImport04.hs → testsuite/tests/default/DefaultImportFail07.hs
- + testsuite/tests/default/DefaultImportFail07.stderr
- testsuite/tests/default/all.T
Changes:
=====================================
compiler/GHC/Tc/Gen/Export.hs
=====================================
@@ -42,7 +42,7 @@ import GHC.Types.SrcLoc as SrcLoc
import GHC.Types.Name
import GHC.Types.Name.Env
import GHC.Types.Name.Set
-import GHC.Types.DefaultEnv (ClassDefaults (cd_class, cd_module), DefaultEnv,
+import GHC.Types.DefaultEnv (ClassDefaults (cd_class), DefaultEnv,
emptyDefaultEnv, filterDefaultEnv, isEmptyDefaultEnv)
import GHC.Types.Avail
import GHC.Types.SourceFile
@@ -192,7 +192,6 @@ rnExports explicit_mod exports
; let dflags = hsc_dflags hsc_env
TcGblEnv { tcg_mod = this_mod
, tcg_rdr_env = rdr_env
- , tcg_default = defaults
, tcg_imports = imports
, tcg_warns = warns
, tcg_src = hsc_src } = tcg_env
@@ -237,15 +236,7 @@ rnExports explicit_mod exports
Nothing -> Nothing
Just _ -> map drop_defaults <$> rn_exports
, tcg_default_exports = case exports of
- Nothing ->
- if xopt LangExt.NamedDefaults dflags then
- -- NamedDefaults on: implicitly export the defaults declared in this module.
- -- Test case: default/DefaultImport04.hs
- filterDefaultEnv ((Just this_mod ==) . cd_module) defaults
- else
- -- NamedDefaults off: do not export any defaults (fixes #25206).
- -- Test case: default/T25206.hs
- emptyDefaultEnv
+ Nothing -> emptyDefaultEnv
_ -> foldMap (foldMap sndOf3) rn_exports
, tcg_dus = tcg_dus tcg_env `plusDU`
usesOnly final_ns
@@ -265,18 +256,17 @@ type DontWarnExportNames = NameEnv (NE.NonEmpty SrcSpan)
~~~~~~~~~~~~~~~~~~~~~~~~~
Named default declarations (see Note [Named default declarations] in
GHC.Tc.Gen.Default) can be exported. A named default declaration is
-exported when
-
-* there is no export list, and we export all locally-declared defaults
-
-* or it is specified in the export list, using the `default` keyword
- and the class name. For example:
+exported only when it's specified in the export list, using the `default`
+keyword and the class name. For example:
module TextWrap (Text, default IsString) where
import Data.String (IsString)
import Data.Text (Text)
default IsString (Text, String)
+A module with no explicit export list does not export any default
+declarations, and neither does the re-export of a whole imported module.
+
The export item `default IsString` is parsed into the `IE` item
IEThingAbs ext (L loc (IEDefault ext "IsString")) doc
=====================================
testsuite/tests/default/DefaultImport04.stdout deleted
=====================================
@@ -1 +0,0 @@
-Product {getProduct = 1}
=====================================
testsuite/tests/default/DefaultImport04.hs → testsuite/tests/default/DefaultImportFail07.hs
=====================================
=====================================
testsuite/tests/default/DefaultImportFail07.stderr
=====================================
@@ -0,0 +1,32 @@
+[1 of 5] Compiling ExportShowSum ( ExportShowSum.hs, ExportShowSum.o )
+[2 of 5] Compiling ExportImplicitMonoidProduct ( ExportImplicitMonoidProduct.hs, ExportImplicitMonoidProduct.o )
+[3 of 5] Compiling ReExportShowSumModule ( ReExportShowSumModule.hs, ReExportShowSumModule.o )
+[4 of 5] Compiling Main ( DefaultImportFail07.hs, DefaultImportFail07.o )
+DefaultImportFail07.hs:6:8: error: [GHC-39999]
+ • Ambiguous type variable ‘a0’ arising from a use of ‘print’
+ prevents the constraint ‘(Show a0)’ from being solved.
+ Probable fix: use a type annotation to specify what ‘a0’ should be.
+ Potentially matching instances:
+ instance Show Ordering -- Defined in ‘GHC.Internal.Show’
+ instance Show Integer -- Defined in ‘GHC.Internal.Show’
+ ...plus 25 others
+ ...plus 19 instances involving out-of-scope types
+ (use -fprint-potential-instances to see them all)
+ • In the expression: print mempty
+ In an equation for ‘main’: main = print mempty
+
+DefaultImportFail07.hs:6:14: error: [GHC-39999]
+ • Ambiguous type variable ‘a0’ arising from a use of ‘mempty’
+ prevents the constraint ‘(Monoid a0)’ from being solved.
+ Probable fix: use a type annotation to specify what ‘a0’ should be.
+ Potentially matching instances:
+ instance Monoid a => Monoid (IO a)
+ -- Defined in ‘GHC.Internal.Base’
+ instance Monoid Ordering -- Defined in ‘GHC.Internal.Base’
+ ...plus 9 others
+ ...plus 7 instances involving out-of-scope types
+ (use -fprint-potential-instances to see them all)
+ • In the first argument of ‘print’, namely ‘mempty’
+ In the expression: print mempty
+ In an equation for ‘main’: main = print mempty
+
=====================================
testsuite/tests/default/all.T
=====================================
@@ -11,8 +11,6 @@ test('default11', normal, compile_and_run, [''])
test('DefaultImport01', [extra_files(['ExportMonoidSum.hs'])], multimod_compile_and_run, ['DefaultImport01', ''])
test('DefaultImport02', [extra_files(['ExportMonoidProduct.hs', 'ExportMonoidSum.hs'])], multimod_compile_and_run, ['DefaultImport02', ''])
test('DefaultImport03', [extra_files(['ExportMonoidSum.hs', 'ReExportMonoidSum.hs'])], multimod_compile_and_run, ['DefaultImport03', ''])
-test('DefaultImport04', [extra_files(['ExportImplicitMonoidProduct.hs', 'ExportShowSum.hs', 'ReExportShowSumModule.hs'])],
- multimod_compile_and_run, ['DefaultImport04', ''])
test('DefaultImport05', [extra_files(['ExportBitsInt.hs'])], multimod_compile_and_run, ['DefaultImport05', ''])
test('DefaultImport07', [extra_files(['ExportMonoidProduct.hs', 'ExportMonoidSum.hs'])], multimod_compile, ['DefaultImport07', '-Wtype-defaults'])
test('DefaultImport08', [extra_files(['ExportMonoidProduct.hs'])], multimod_compile, ['DefaultImport08', '-Wtype-defaults'])
@@ -22,6 +20,8 @@ test('DefaultImportFail03', [extra_files(['ExportMonoidSum.hs', 'UnExportMonoidS
test('DefaultImportFail04', [extra_files(['ExportShowSum.hs', 'ReExportShowSumModule.hs'])], multimod_compile_fail, ['DefaultImportFail04', ''])
test('DefaultImportFail05', [extra_files(['ExportMonoidProduct.hs', 'ExportShowSum.hs'])], multimod_compile_fail, ['DefaultImportFail05', ''])
test('DefaultImportFail06', [extra_files(['ExportBitsInt.hs'])], multimod_compile_fail, ['DefaultImportFail06', ''])
+test('DefaultImportFail07', [extra_files(['ExportImplicitMonoidProduct.hs', 'ExportShowSum.hs', 'ReExportShowSumModule.hs'])],
+ multimod_compile_fail, ['DefaultImportFail07', ''])
test('default-fail01', normal, compile_fail, [''])
test('default-fail02', normal, compile_fail, [''])
test('default-fail03', normal, compile_fail, [''])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9d20a787490a3b758da89d60eac63c70578f5ad5
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9d20a787490a3b758da89d60eac63c70578f5ad5
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/20240918/456a23f8/attachment-0001.html>
More information about the ghc-commits
mailing list