clash-lib
Copyright(C) 2026 QBayLogic B.V.
LicenseBSD2 (see the file LICENSE)
MaintainerQBayLogic B.V. <devops@qbaylogic.com>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Clash.Warning

Description

Named warnings and the options controlling them.

Every warning Clash can emit has a name and can be controlled individually with GHC-style flags:

-W<name>
enable the warning
-Wno-<name>
disable the warning
-Werror=<name>
enable the warning and promote it to an error
-Wwarn=<name>, -Wno-error=<name>
demote the warning back to a warning, also exempting it from a global -Werror

Note that Clash parses its flags in a separate pass from GHC's, so ordering between GHC's global -Werror and -Wwarn=<name> is not positional: an explicit -Wwarn=<name> always wins over a global -Werror. Ordering among the Clash warning flags themselves is positional (last one wins).

Synopsis

Documentation

data ClashWarning Source #

Warnings Clash can emit. See the module documentation of Clash.Warning for the command line flags controlling each of these.

Constructors

WarnDubiousPrimitive

A primitive marked with WarnAlways was instantiated, e.g. a primitive that only approximates its Haskell model.

Flag: -Wclash-dubious-primitive

WarnNonSynthesizable

A primitive marked with WarnNonSynthesizable was instantiated outside of a test bench context.

Flag: -Wclash-non-synthesizable

WarnPrimitiveDefinition

A primitive's Haskell definition looks problematic: it isn't marked OPAQUE, its result is always an error, or its blackbox uses arguments the Haskell definition doesn't use.

Flag: -Wclash-primitive-definition

WarnCastSpecialization

A function is specialized on a non work-free cast, possibly duplicating work.

Flag: -Wclash-cast-specialization

WarnIntegerNarrowing

A toInteger conversion narrows its argument to the width of Int, possibly dropping most significant bits.

Flag: -Wclash-integer-narrowing

WarnUnmatchableConstant

A case subject evaluated to a constant that matches none of the alternatives, usually a missing reduction rule in the primitive evaluator. Only reported when invariants are being checked (-fclash-debug).

Flag: -Wclash-unmatchable-constant

Instances

Instances details
Bounded ClashWarning Source # 
Instance details

Defined in Clash.Warning

Enum ClashWarning Source # 
Instance details

Defined in Clash.Warning

Generic ClashWarning Source # 
Instance details

Defined in Clash.Warning

Associated Types

type Rep ClashWarning :: Type -> Type #

Show ClashWarning Source # 
Instance details

Defined in Clash.Warning

NFData ClashWarning Source # 
Instance details

Defined in Clash.Warning

Methods

rnf :: ClashWarning -> () #

Eq ClashWarning Source # 
Instance details

Defined in Clash.Warning

Ord ClashWarning Source # 
Instance details

Defined in Clash.Warning

Hashable ClashWarning Source # 
Instance details

Defined in Clash.Warning

type Rep ClashWarning Source # 
Instance details

Defined in Clash.Warning

type Rep ClashWarning = D1 ('MetaData "ClashWarning" "Clash.Warning" "clash-lib-1.11.0-inplace" 'False) ((C1 ('MetaCons "WarnDubiousPrimitive" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "WarnNonSynthesizable" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WarnPrimitiveDefinition" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "WarnCastSpecialization" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "WarnIntegerNarrowing" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WarnUnmatchableConstant" 'PrefixI 'False) (U1 :: Type -> Type))))

warningName :: ClashWarning -> String Source #

The name of a warning as used in command line flags, e.g. clash-dubious-primitive for WarnDubiousPrimitive.

Warning options

data WarningOpts Source #

Which warnings are enabled, and which of them are fatal. Construct with defWarningOpts and the state transitions below; query with wopt and woptFatal.

Constructors

WarningOpts 

Fields

Instances

Instances details
Generic WarningOpts Source # 
Instance details

Defined in Clash.Warning

Associated Types

type Rep WarningOpts :: Type -> Type #

Show WarningOpts Source # 
Instance details

Defined in Clash.Warning

NFData WarningOpts Source # 
Instance details

Defined in Clash.Warning

Methods

rnf :: WarningOpts -> () #

Eq WarningOpts Source # 
Instance details

Defined in Clash.Warning

Hashable WarningOpts Source # 
Instance details

Defined in Clash.Warning

type Rep WarningOpts Source # 
Instance details

Defined in Clash.Warning

type Rep WarningOpts = D1 ('MetaData "WarningOpts" "Clash.Warning" "clash-lib-1.11.0-inplace" 'False) (C1 ('MetaCons "WarningOpts" 'PrefixI 'True) (S1 ('MetaSel ('Just "warn_enabled") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Set ClashWarning)) :*: (S1 ('MetaSel ('Just "warn_fatal") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Set ClashWarning)) :*: S1 ('MetaSel ('Just "warn_nonFatal") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Set ClashWarning)))))

defWarningOpts :: WarningOpts Source #

All warnings enabled, none fatal

wopt :: ClashWarning -> WarningOpts -> Bool Source #

Is the given warning enabled?

woptFatal :: Bool -> ClashWarning -> WarningOpts -> Bool Source #

Should the given warning be promoted to an error? The first argument indicates whether all warnings should be treated as errors (-Werror).

Flag-parsing state transitions

promoteWarning :: ClashWarning -> WarningOpts -> WarningOpts Source #

-Werror=<name>. Implies -W<name>, like in GHC.

demoteWarning :: ClashWarning -> WarningOpts -> WarningOpts Source #

-Wwarn=<name> / -Wno-error=<name>