Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

5 changed files:

Changes:

  • compiler/GHC/Driver/MakeFile.hs
    ... ... @@ -55,6 +55,7 @@ import Data.IORef
    55 55
     import qualified Data.Set as Set
    
    56 56
     import GHC.Iface.Errors.Types
    
    57 57
     import Data.Either
    
    58
    +import GHC.Data.Bag (listToBag)
    
    58 59
     
    
    59 60
     -----------------------------------------------------------------
    
    60 61
     --
    
    ... ... @@ -237,19 +238,6 @@ processDeps dflags hsc_env excl_mods root hdl (AcyclicSCC (ModuleNode _ (ModuleN
    237 238
                   obj_file  = msObjFilePath node
    
    238 239
                   obj_files = insertSuffixes obj_file extra_suffixes
    
    239 240
     
    
    240
    -              do_imp loc is_boot pkg_qual imp_mod
    
    241
    -                = do { mb_hi <- findDependency hsc_env loc pkg_qual imp_mod
    
    242
    -                                               is_boot include_pkg_deps
    
    243
    -                     ; case mb_hi of {
    
    244
    -                           Nothing      -> return () ;
    
    245
    -                           Just hi_file -> do
    
    246
    -                     { let hi_files = insertSuffixes hi_file extra_suffixes
    
    247
    -                           write_dep (obj,hi) = writeDependency root hdl [obj] hi
    
    248
    -
    
    249
    -                        -- Add one dependency for each suffix;
    
    250
    -                        -- e.g.         A.o   : B.hi
    
    251
    -                        --              A.x_o : B.x_hi
    
    252
    -                     ; mapM_ write_dep (obj_files `zip` hi_files) }}}
    
    253 241
     
    
    254 242
     
    
    255 243
                     -- Emit std dependency of the object(s) on the source file
    
    ... ... @@ -280,15 +268,33 @@ processDeps dflags hsc_env excl_mods root hdl (AcyclicSCC (ModuleNode _ (ModuleN
    280 268
     
    
    281 269
                     -- Emit a dependency for each import
    
    282 270
     
    
    283
    -        ; let do_imps is_boot idecls = sequence_
    
    284
    -                    [ do_imp loc is_boot mb_pkg mod
    
    271
    +        ; let find_dep loc is_boot pkg_qual imp_mod = findDependency hsc_env loc pkg_qual imp_mod is_boot include_pkg_deps
    
    272
    +
    
    273
    +              find_deps is_boot idecls = sequence
    
    274
    +                    [ find_dep loc is_boot mb_pkg mod
    
    285 275
                         | (_lvl, mb_pkg, L loc mod) <- idecls,
    
    286 276
                           mod `notElem` excl_mods ]
    
    287 277
     
    
    288
    -        ; do_imps IsBoot (map ((,,) NormalLevel NoPkgQual) (ms_srcimps node))
    
    289
    -        ; do_imps NotBoot (ms_imps node)
    
    290
    -        }
    
    278
    +              do_imp hi_file = do
    
    279
    +                let hi_files = insertSuffixes hi_file extra_suffixes
    
    280
    +                    write_dep (obj,hi) = writeDependency root hdl [obj] hi
    
    281
    +
    
    282
    +                 -- Add one dependency for each suffix;
    
    283
    +                 -- e.g.         A.o   : B.hi
    
    284
    +                 --              A.x_o : B.x_hi
    
    285
    +                mapM_ write_dep (obj_files `zip` hi_files)
    
    291 286
     
    
    287
    +        ; (missing_boot_dep_errs, boot_deps) <- partitionEithers <$> find_deps IsBoot (map ((,,) NormalLevel NoPkgQual) (ms_srcimps node))
    
    288
    +        ; (missing_not_boot_dep_errs, not_boot_deps) <- partitionEithers <$> find_deps NotBoot (ms_imps node)
    
    289
    +
    
    290
    +        ; let all_missing_errors = missing_boot_dep_errs ++ missing_not_boot_dep_errs
    
    291
    +
    
    292
    +        ; if null all_missing_errors
    
    293
    +            then mapM_ (mapM_ do_imp) (boot_deps ++ not_boot_deps)
    
    294
    +            else do
    
    295
    +              let sec = initSourceErrorContext (hsc_dflags hsc_env)
    
    296
    +              throwErrors sec (mkMessages (listToBag all_missing_errors))
    
    297
    +        }
    
    292 298
     
    
    293 299
     findDependency  :: HscEnv
    
    294 300
                     -> SrcSpan
    
    ... ... @@ -296,7 +302,7 @@ findDependency :: HscEnv
    296 302
                     -> ModuleName           -- Imported module
    
    297 303
                     -> IsBootInterface      -- Source import
    
    298 304
                     -> Bool                 -- Record dependency on package modules
    
    299
    -                -> IO (Maybe FilePath)  -- Interface file
    
    305
    +                -> IO (Either (MsgEnvelope GhcMessage) (Maybe FilePath))  -- Interface file
    
    300 306
     findDependency hsc_env srcloc pkg imp is_boot include_pkg_deps = do
    
    301 307
       -- Find the module; this will be fast because
    
    302 308
       -- we've done it once during downsweep
    
    ... ... @@ -305,16 +311,15 @@ findDependency hsc_env srcloc pkg imp is_boot include_pkg_deps = do
    305 311
         Found loc _
    
    306 312
             -- Home package: just depend on the .hi or hi-boot file
    
    307 313
             | isJust (ml_hs_file loc) || include_pkg_deps
    
    308
    -        -> return (Just (ml_hi_file loc))
    
    314
    +        -> return (Right (Just (ml_hi_file loc)))
    
    309 315
     
    
    310 316
             -- Not in this package: we don't need a dependency
    
    311 317
             | otherwise
    
    312
    -        -> return Nothing
    
    318
    +        -> return (Right Nothing)
    
    313 319
     
    
    314 320
         fail ->
    
    315
    -      let sec = initSourceErrorContext (hsc_dflags hsc_env)
    
    316
    -      in
    
    317
    -        throwOneError sec $
    
    321
    +      return $
    
    322
    +        Left $
    
    318 323
               mkPlainErrorMsgEnvelope srcloc $
    
    319 324
               GhcDriverMessage $ DriverInterfaceError $
    
    320 325
                  (Can'tFindInterface (cannotFindModule hsc_env imp fail) (LookingForModule imp is_boot))
    

  • testsuite/tests/driver/Makefile
    ... ... @@ -415,6 +415,10 @@ test200:
    415 415
     	"$(TEST_HC)" $(TEST_HC_OPTS) -M -dep-suffix "" -dep-makefile $(DEPFILE200) D200.hs B200/C.hs A200.hs
    
    416 416
     	test -f $(DEPFILE200)
    
    417 417
     
    
    418
    +# Test that we produce "could not find module" errors for _all_ missing imports.
    
    419
    +T26551:
    
    420
    +	"$(TEST_HC)" $(TEST_HC_OPTS) -M T26551.hs || true
    
    421
    +
    
    418 422
     # -----------------------------------------------------------------------------
    
    419 423
     
    
    420 424
     T2566::
    

  • testsuite/tests/driver/T26551.hs
    1
    +module Main where
    
    2
    +
    
    3
    +import Foo
    
    4
    +import Bar
    
    5
    +import Baz

  • testsuite/tests/driver/T26551.stderr
    1
    +T26551.hs:3:8: [GHC-87110]
    
    2
    +    Could not find module ‘Foo’.
    
    3
    +    Use -v to see a list of the files searched for.
    
    4
    +
    
    5
    +T26551.hs:4:8: [GHC-87110]
    
    6
    +    Could not find module ‘Bar’.
    
    7
    +    Use -v to see a list of the files searched for.
    
    8
    +
    
    9
    +T26551.hs:5:8: [GHC-87110]
    
    10
    +    Could not find module ‘Baz’.
    
    11
    +    Use -v to see a list of the files searched for.

  • testsuite/tests/driver/all.T
    ... ... @@ -332,3 +332,4 @@ test('t25150', [extra_files(["t25150"])], multimod_compile, ['Main.hs', '-v0 -wo
    332 332
     test('T25382', normal, makefile_test, [])
    
    333 333
     test('T26018', req_c, makefile_test, [])
    
    334 334
     test('T24120', normal, compile, ['-Wunused-packages -hide-all-packages -package base -package system-cxx-std-lib'])
    
    335
    +test('T26551', [extra_files(['T26551.hs'])], makefile_test, [])