@@ -3,6 +3,7 @@
4{-# LANGUAGE OverloadedStrings #-}
4{-# LANGUAGE OverloadedStrings #-}
5{-# LANGUAGE RankNTypes #-}
5{-# LANGUAGE RankNTypes #-}
7-- | Based on https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/API.
8-- | Based on https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/API.
8-- Given a list of paths to find libraries, and a file to compile, produce a list of 'CoreModule' values.
9-- Given a list of paths to find libraries, and a file to compile, produce a list of 'CoreModule' values.
@@ -414,7 +415,9 @@ getModSummaryFromBuffer fp (contents, fileDate) dflags parsed = do
414 { ml_hs_file = Just fp
415 { ml_hs_file = Just fp
415 , ml_hi_file = replaceExtension fp "hi"
416 , ml_hi_file = replaceExtension fp "hi"
416 , ml_obj_file = replaceExtension fp "o"
417 , ml_obj_file = replaceExtension fp "o"
417 , ml_hie_file = replaceExtension fp "hie"
419 , ml_hie_file = replaceExtension fp "hie"
418 -- This does not consider the dflags configuration
421 -- This does not consider the dflags configuration
419 -- (-osuf and -hisuf, object and hi dir.s).
422 -- (-osuf and -hisuf, object and hi dir.s).
420 -- However, we anyway don't want to generate them.
423 -- However, we anyway don't want to generate them.
@@ -433,7 +436,9 @@ getModSummaryFromBuffer fp (contents, fileDate) dflags parsed = do
433 , ms_hsc_src = HsSrcFile
436 , ms_hsc_src = HsSrcFile
434 , ms_obj_date = Nothing
437 , ms_obj_date = Nothing
435 , ms_iface_date = Nothing
438 , ms_iface_date = Nothing
436 , ms_hie_date = Nothing
440 , ms_hie_date = Nothing
437 , ms_srcimps = [] -- source imports are not allowed
442 , ms_srcimps = [] -- source imports are not allowed
438 , ms_parsed_mod = Nothing
443 , ms_parsed_mod = Nothing
@@ -450,8 +455,13 @@ parseFileContents preprocessor filename (time, contents) = do
450 let loc = mkRealSrcLoc (mkFastString filename) 1 1
455 let loc = mkRealSrcLoc (mkFastString filename) 1 1
451 dflags <- parsePragmasIntoDynFlags filename contents
456 dflags <- parsePragmasIntoDynFlags filename contents
452 case unP Parser.parseModule (mkPState dflags contents loc) of
457 case unP Parser.parseModule (mkPState dflags contents loc) of
459+ PFailed getMessages _ _ ->
460+ Ex.throwE $ toDiagnostics dflags $ snd $ getMessages dflags
453 PFailed s ->
462 PFailed s ->
454 Ex.throwE $ toDiagnostics dflags $ snd $ getMessages s dflags
463 Ex.throwE $ toDiagnostics dflags $ snd $ getMessages s dflags
455 POk pst rdr_module ->
465 POk pst rdr_module ->
456 let hpm_annotations =
466 let hpm_annotations =
457 (Map.fromListWith (++) $ annotations pst,
467 (Map.fromListWith (++) $ annotations pst,