diff options
-rw-r--r-- | compiler/GHC/Parser/Header.hs | 14 | ||||
-rw-r--r-- | testsuite/tests/parser/should_compile/T19082.hs | 7 | ||||
-rw-r--r-- | testsuite/tests/parser/should_compile/all.T | 1 | ||||
-rw-r--r-- | testsuite/tests/parser/should_fail/T17045.hs | 8 | ||||
-rw-r--r-- | testsuite/tests/parser/should_fail/T17045.stderr | 5 | ||||
-rw-r--r-- | testsuite/tests/parser/should_fail/all.T | 1 |
6 files changed, 31 insertions, 5 deletions
diff --git a/compiler/GHC/Parser/Header.hs b/compiler/GHC/Parser/Header.hs index 4e2c297bea..5abb0497d4 100644 --- a/compiler/GHC/Parser/Header.hs +++ b/compiler/GHC/Parser/Header.hs @@ -129,11 +129,15 @@ mkPrelImports this_mod loc implicit_prelude import_decls = [] | otherwise = [preludeImportDecl] where - explicit_prelude_import - = notNull [ () | L _ (ImportDecl { ideclName = mod - , ideclPkgQual = Nothing }) - <- import_decls - , unLoc mod == pRELUDE_NAME ] + explicit_prelude_import = any is_prelude_import import_decls + + is_prelude_import (L _ decl) = + unLoc (ideclName decl) == pRELUDE_NAME + -- allow explicit "base" package qualifier (#19082, #17045) + && case ideclPkgQual decl of + Nothing -> True + Just b -> sl_fs b == unitIdFS baseUnitId + preludeImportDecl :: LImportDecl GhcPs preludeImportDecl diff --git a/testsuite/tests/parser/should_compile/T19082.hs b/testsuite/tests/parser/should_compile/T19082.hs new file mode 100644 index 0000000000..bd5c4f048f --- /dev/null +++ b/testsuite/tests/parser/should_compile/T19082.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE PackageImports #-} + +module Foo (String) where + +import "base" Prelude hiding (String) + +data String = String diff --git a/testsuite/tests/parser/should_compile/all.T b/testsuite/tests/parser/should_compile/all.T index 0f63299386..4aa6d17ec0 100644 --- a/testsuite/tests/parser/should_compile/all.T +++ b/testsuite/tests/parser/should_compile/all.T @@ -173,3 +173,4 @@ test('T18130', normal, compile, ['']) test('T18834a', normal, compile, ['']) test('T18834b', normal, compile, ['']) test('T12862', normal, compile, ['']) +test('T19082', normal, compile, ['']) diff --git a/testsuite/tests/parser/should_fail/T17045.hs b/testsuite/tests/parser/should_fail/T17045.hs new file mode 100644 index 0000000000..7b3fb01f4d --- /dev/null +++ b/testsuite/tests/parser/should_fail/T17045.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE PackageImports #-} + +module Bug where + +import "base" Prelude (zip) + +wobbly :: String +wobbly = "hello" diff --git a/testsuite/tests/parser/should_fail/T17045.stderr b/testsuite/tests/parser/should_fail/T17045.stderr new file mode 100644 index 0000000000..fdcf4422ea --- /dev/null +++ b/testsuite/tests/parser/should_fail/T17045.stderr @@ -0,0 +1,5 @@ + +T17045.hs:7:11: error: + Not in scope: type constructor or class ‘String’ + Perhaps you want to add ‘String’ to the import list + in the import of ‘Prelude’ (T17045.hs:5:1-27). diff --git a/testsuite/tests/parser/should_fail/all.T b/testsuite/tests/parser/should_fail/all.T index f79c14fdc1..88a37ec2ba 100644 --- a/testsuite/tests/parser/should_fail/all.T +++ b/testsuite/tests/parser/should_fail/all.T @@ -174,3 +174,4 @@ test('T18251d', normal, compile_fail, ['']) test('T18251e', normal, compile_fail, ['']) test('T18251f', normal, compile_fail, ['']) test('T12446', normal, compile_fail, ['']) +test('T17045', normal, compile_fail, ['']) |