clash-lang / clash-compiler

Haskell to VHDL/Verilog/SystemVerilog compiler
https://clash-lang.org/
Other
1.43k stars 151 forks source link

Workaround "Pattern match has inaccessible right hand side" bug #2611

Closed leonschoorl closed 10 months ago

leonschoorl commented 10 months ago

When using GHC < 9 .../ICE40/Blackboxes/IO.hs sometimes(?) warns:

    Pattern match has inaccessible right hand side
    In a pattern binding in
         a pattern guard for
           an equation for ‘sbioTemplate’:
        [_HasCallStack,
         (clk, clkTy, _),
         (en, _enTy, _),
         (pinConfig, _pinTy, pinConfigLiteral -> ()),
         (packagePin, packagePinTy, _),
         (latchInput, Bit, _),
         (dOut0, Bit, _),
         (dOut1, Bit, _),
         (outputEnable, Bool, _)]
        <-
        ...

And because we run with -Werror on CI this causes compilation to fail. This works around that by explicitly turning it back into a warning.

Still TODO:

leonschoorl commented 10 months ago

It's very weird this only happens sometimes.

I've compared the outputs of various -ddump-... options between runs where it warns and runs where it doesn't warn, but nothing much changes. Except for dump-simpl-iterations where on a run with warnings sbioTemplate has a couple of extra unused local let bindings:

k :: Identifier -> Ap (State s) Doc
k :: (Identifier, s) -> Data.Functor.Identity.Identity (Doc, s)

But they're unused and get eliminated later on in the simplifier and the final output of the simplifier is identical. Therefor I believe we can safely ignore the warning. And because it only seems to happen on GHC < 9, it's probably not worth reporting.