Skip to content

zipEqual: left list is longer #2812

@kleinreact

Description

@kleinreact

The following reproducer

{-# LANGUAGE AllowAmbiguousTypes #-}
{-# OPTIONS_GHC -fconstraint-solver-iterations=20 #-}
module Top where

import Clash.Prelude

import Data.Proxy
import Data.Type.Bool

data T = A

type family TF (t :: T) :: Nat where
  TF A = 32

data TFacts (t :: T) where
  TFacts :: KnownNat (TF t)  => Proxy t -> TFacts t

class    KnownT t where knownT :: TFacts t
instance KnownT A where knownT  = TFacts Proxy

type RSF t n = If (n <=? TF t) (Div (TF t) n) 1

go ::
  forall t n.
  ( KnownT t, KnownNat n, 1 <= n
  , 1 <= If (n <=? (TF t)) (Div (TF t) n) 1
  ) => BitVector n -> Vec (RSF t n) (BitVector n)
go inp | TFacts{} <- knownT @t = bitCoerce
  $ let ext :: BitVector n -> BitVector (n * RSF t n)
        ext = extend @_ @_ @(n * RSF t n - n)
     in unpack (ext inp) :: Unsigned (n * RSF t n)

topEntity ::
  HiddenClockResetEnable System =>
  Signal System (Vec (RSF A 8) (BitVector 8))
topEntity = go @A @8 <$> pure 0

produces a

Clash: Compiling Top.topEntity

<no location info>: error:
    Clash error call:
    zipEqual: left list is longer
    CallStack (from HasCallStack):
      error, called at src/Data/List/Extra.hs:140:19 in clash-lib-1.9.0-inplace:Data.List.Extra
      zipEqual, called at src/Clash/Normalize/Transformations/Case.hs:206:19 in clash-lib-1.9.0-inplace:Clash.Normalize.Transformations.Case
      caseCon', called at src/Clash/Normalize/Transformations/Case.hs:154:32 in clash-lib-1.9.0-inplace:Clash.Normalize.Transformations.Case
      caseCon, called at src/Clash/Normalize/Transformations/Case.hs:273:23 in clash-lib-1.9.0-inplace:Clash.Normalize.Transformations.Case
      caseCon', called at src/Clash/Normalize/Transformations/Case.hs:154:32 in clash-lib-1.9.0-inplace:Clash.Normalize.Transformations.Case
      caseCon, called at src/Clash/Normalize/Strategy.hs:91:36 in clash-lib-1.9.0-inplace:Clash.Normalize.Strategy

but only if the debug flag has been enabled for clash-lib. Otherwise, it compiles just fine.

I don't think that this one is related to #2376, although producing the same error message, as the example makes no use of unsafeCoerce at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions