ghc-lib-parser-9.4.7.20230826: The GHC API, decoupled from GHC versions
Safe HaskellSafe-Inferred
LanguageHaskell2010

GHC.Driver.Errors.Types

Synopsis

Documentation

data GhcMessage where Source #

The umbrella type that encompasses all the different messages that GHC might output during the different compilation stages. See Note [GhcMessage].

Constructors

GhcPsMessage :: PsMessage -> GhcMessage

A message from the parsing phase.

GhcTcRnMessage :: TcRnMessage -> GhcMessage

A message from typecheck/renaming phase.

GhcDsMessage :: DsMessage -> GhcMessage

A message from the desugaring (HsToCore) phase.

GhcDriverMessage :: DriverMessage -> GhcMessage

A message from the driver.

GhcUnknownMessage :: forall a. (Diagnostic a, Typeable a) => a -> GhcMessage

An "escape" hatch which can be used when we don't know the source of the message or if the message is not one of the typed ones. The Diagnostic and Typeable constraints ensure that if we know, at pattern-matching time, the originating type, we can attempt a cast and access the fully-structured error. This would be the case for a GHC plugin that offers a domain-specific error type but that doesn't want to place the burden on IDEs/application code to "know" it. The Diagnostic constraint ensures that worst case scenario we can still render this into something which can be eventually converted into a DecoratedSDoc.

data DriverMessage where Source #

A message from the driver.

Constructors

DriverUnknownMessage :: (Diagnostic a, Typeable a) => a -> DriverMessage

Simply wraps a generic Diagnostic message a.

DriverPsHeaderMessage :: !PsMessage -> DriverMessage

A parse error in parsing a Haskell file header during dependency analysis

DriverMissingHomeModules :: UnitId -> [ModuleName] -> !BuildingCabalPackage -> DriverMessage

DriverMissingHomeModules is a warning (controlled with -Wmissing-home-modules) that arises when running GHC in --make mode when some modules needed for compilation are not included on the command line. For example, if A imports B, `ghc --make A.hs` will cause this warning, while `ghc --make A.hs B.hs` will not.

Useful for cabal to ensure GHC won't pick up modules listed neither in 'exposed-modules' nor in 'other-modules'.

Test case: warningsshould_compileMissingMod

DriverUnknownReexportedModules :: UnitId -> [ModuleName] -> DriverMessage

DriverUnknown is a warning that arises when a user tries to reexport a module which isn't part of that unit.

DriverUnknownHiddenModules :: UnitId -> [ModuleName] -> DriverMessage

DriverUnknownHiddenModules is a warning that arises when a user tries to hide a module which isn't part of that unit.

DriverUnusedPackages :: [(UnitId, PackageName, Version, PackageArg)] -> DriverMessage

DriverUnusedPackages occurs when when package is requested on command line, but was never needed during compilation. Activated by -Wunused-packages.

Test cases: warningsshould_compileUnusedPackages

DriverUnnecessarySourceImports :: !ModuleName -> DriverMessage

DriverUnnecessarySourceImports (controlled with -Wunused-imports) occurs if there are imports which are not necessary. See warnUnnecessarySourceImports in Make.

Test cases: warningsshould_compileT10637

DriverDuplicatedModuleDeclaration :: !Module -> [FilePath] -> DriverMessage

DriverDuplicatedModuleDeclaration occurs if a module A is declared in multiple files.

Test cases: None.

DriverModuleNotFound :: !ModuleName -> DriverMessage

DriverModuleNotFound occurs if a module A can't be found.

Test cases: None.

DriverFileModuleNameMismatch :: !ModuleName -> !ModuleName -> DriverMessage

DriverFileModuleNameMismatch occurs if a module A is defined in a file with a different name. The first field is the name written in the source code; the second argument is the name extracted from the filename.

Test cases: modulemod178, driver/bug1677

DriverUnexpectedSignature :: !ModuleName -> !BuildingCabalPackage -> GenInstantiations UnitId -> DriverMessage

DriverUnexpectedSignature occurs when GHC encounters a module A that imports a signature file which is neither in the signatures section of a '.cabal' file nor in any package in the home modules.

Example:

  • - MyStr.hsig is defined, but not added to signatures in the '.cabal' file. signature MyStr where data Str
  • - A.hs, which tries to import the signature. module A where import MyStr

Test cases: driver/T12955

DriverFileNotFound :: !FilePath -> DriverMessage

DriverFileNotFound occurs when the input file (e.g. given on the command line) can't be found.

Test cases: None.

DriverStaticPointersNotSupported :: DriverMessage

DriverStaticPointersNotSupported occurs when the StaticPointers extension is used in an interactive GHCi context.

Test cases: ghciscriptsStaticPtr

DriverBackpackModuleNotFound :: !ModuleName -> DriverMessage

DriverBackpackModuleNotFound occurs when Backpack can't find a particular module during its dependency analysis.

Test cases: -

DriverUserDefinedRuleIgnored :: !(RuleDecl GhcTc) -> DriverMessage

DriverUserDefinedRuleIgnored is a warning that occurs when user-defined rules are ignored. This typically happens when Safe Haskell.

Test cases:

testssafeHaskellsafeInfered/UnsafeWarn05 testssafeHaskellsafeInfered/UnsafeWarn06 testssafeHaskellsafeInfered/UnsafeWarn07 testssafeHaskellsafeInfered/UnsafeInfered11 testssafeHaskellsafeLanguage/SafeLang03

DriverMixedSafetyImport :: !ModuleName -> DriverMessage

DriverMixedSafetyImport is an error that occurs when a module is imported both as safe and unsafe.

Test cases:

testssafeHaskellsafeInfered/Mixed03 testssafeHaskellsafeInfered/Mixed02

DriverCannotLoadInterfaceFile :: !Module -> DriverMessage

DriverCannotLoadInterfaceFile is an error that occurs when we cannot load the interface file for a particular module. This can happen for example in the context of Safe Haskell, when we have to load a module to check if it can be safely imported.

Test cases: None.

DriverInferredSafeModule :: !Module -> DriverMessage

DriverInferredSafeImport is a warning (controlled by the Opt_WarnSafe flag) that occurs when a module is inferred safe.

Test cases: None.

DriverMarkedTrustworthyButInferredSafe :: !Module -> DriverMessage

DriverMarkedTrustworthyButInferredSafe is a warning (controlled by the Opt_WarnTrustworthySafe flag) that occurs when a module is marked trustworthy in SafeHaskell but it has been inferred safe.

Test cases: testssafeHaskellsafeInfered/TrustworthySafe02 testssafeHaskellsafeInfered/TrustworthySafe03

DriverInferredSafeImport :: !Module -> DriverMessage

DriverInferredSafeImport is a warning (controlled by the Opt_WarnInferredSafeImports flag) that occurs when a safe-inferred module is imported from a safe module.

Test cases: None.

DriverCannotImportUnsafeModule :: !Module -> DriverMessage

DriverCannotImportUnsafeModule is an error that occurs when an usafe module is being imported from a safe one.

Test cases: None.

DriverMissingSafeHaskellMode :: !Module -> DriverMessage

DriverMissingSafeHaskellMode is a warning (controlled by the Opt_WarnMissingSafeHaskellMode flag) that occurs when a module is using SafeHaskell features but SafeHaskell mode is not enabled.

Test cases: None.

DriverPackageNotTrusted :: !UnitState -> !UnitId -> DriverMessage

DriverPackageNotTrusted is an error that occurs when a package is required to be trusted but it isn't.

Test cases: testssafeHaskellcheck/Check01 testssafeHaskellcheck/Check08 testssafeHaskellcheck/Check06 testssafeHaskellcheckpkg01ImpSafeOnly09 testssafeHaskellcheckpkg01ImpSafe03 testssafeHaskellcheckpkg01ImpSafeOnly07 testssafeHaskellcheckpkg01ImpSafeOnly08

DriverCannotImportFromUntrustedPackage :: !UnitState -> !Module -> DriverMessage

DriverCannotImportFromUntrustedPackage is an error that occurs in the context of Safe Haskell when trying to import a module coming from an untrusted package.

Test cases: testssafeHaskellcheck/Check09 testssafeHaskellcheckpkg01ImpSafe01 testssafeHaskellcheckpkg01ImpSafe04 testssafeHaskellcheckpkg01ImpSafeOnly03 testssafeHaskellcheckpkg01ImpSafeOnly05 testssafeHaskellflags/SafeFlags17 testssafeHaskellflags/SafeFlags22 testssafeHaskellflags/SafeFlags23 testssafeHaskellghci/p11 testssafeHaskellghci/p12 testssafeHaskellghci/p17 testssafeHaskellghci/p3 testssafeHaskellsafeInfered/UnsafeInfered01 testssafeHaskellsafeInfered/UnsafeInfered02 testssafeHaskellsafeInfered/UnsafeInfered02 testssafeHaskellsafeInfered/UnsafeInfered03 testssafeHaskellsafeInfered/UnsafeInfered05 testssafeHaskellsafeInfered/UnsafeInfered06 testssafeHaskellsafeInfered/UnsafeInfered09 testssafeHaskellsafeInfered/UnsafeInfered10 testssafeHaskellsafeInfered/UnsafeInfered11 testssafeHaskellsafeInfered/UnsafeWarn01 testssafeHaskellsafeInfered/UnsafeWarn03 testssafeHaskellsafeInfered/UnsafeWarn04 testssafeHaskellsafeInfered/UnsafeWarn05 testssafeHaskellunsafeLibs/BadImport01 testssafeHaskellunsafeLibs/BadImport06 testssafeHaskellunsafeLibs/BadImport07 testssafeHaskellunsafeLibs/BadImport08 testssafeHaskellunsafeLibs/BadImport09 testssafeHaskellunsafeLibs/Dep05 testssafeHaskellunsafeLibs/Dep06 testssafeHaskellunsafeLibs/Dep07 testssafeHaskellunsafeLibs/Dep08 testssafeHaskellunsafeLibs/Dep09 testssafeHaskellunsafeLibs/Dep10

DriverRedirectedNoMain :: !ModuleName -> DriverMessage 
DriverHomePackagesNotClosed :: ![UnitId] -> DriverMessage 

type DriverMessages = Messages DriverMessage Source #

A collection of driver messages

data PsMessage Source #

Constructors

PsHeaderMessage !PsHeaderMessage

A group of parser messages emitted in Header. See Note [Messages from GHC.Parser.Header].

data BuildingCabalPackage Source #

Pass to a DriverMessage the information whether or not the '-fbuilding-cabal-package' flag is set.

type WarningMessages = Messages GhcMessage Source #

A collection of warning messages. INVARIANT: Each GhcMessage in the collection should have SevWarning severity.

type ErrorMessages = Messages GhcMessage Source #

A collection of error messages. INVARIANT: Each GhcMessage in the collection should have SevError severity.

type WarnMsg = MsgEnvelope GhcMessage Source #

A single warning message. INVARIANT: It must have SevWarning severity.

Constructors

ghcUnknownMessage :: (Diagnostic a, Typeable a) => a -> GhcMessage Source #

Creates a new GhcMessage out of any diagnostic. This function is also provided to ease the integration of #18516 by allowing diagnostics to be wrapped into the general (but structured) GhcMessage type, so that the conversion can happen gradually. This function should not be needed within GHC, as it would typically be used by plugin or library authors (see comment for the GhcUnknownMessage type constructor)

Utility functions

hoistTcRnMessage :: Monad m => m (Messages TcRnMessage, a) -> m (Messages GhcMessage, a) Source #

Abstracts away the frequent pattern where we are calling ioMsgMaybe on the result of 'IO (Messages TcRnMessage, a)'.

hoistDsMessage :: Monad m => m (Messages DsMessage, a) -> m (Messages GhcMessage, a) Source #

Abstracts away the frequent pattern where we are calling ioMsgMaybe on the result of 'IO (Messages DsMessage, a)'.

checkBuildingCabalPackage :: DynFlags -> BuildingCabalPackage Source #

Checks if we are building a cabal package by consulting the DynFlags.