Skip to content

Prelude.!!: index to large #2831

Description

@kleinreact

The following

f :: forall n. SNat n -> Unsigned 4
f n@SNat = case compareSNat n (SNat @15) of
  SNatLE -> at @n @(16 - n - 1) SNat vec
  SNatGT -> 0
 where
  vec :: Vec 16 (Unsigned 4)
  vec = repeat 0

topEntity :: HiddenClockResetEnable System => Signal System (Unsigned 4)
topEntity = pure $ f d17

results in

<no location info>: error:
    Clash error call:
    Prelude.!!: index too large
    CallStack (from HasCallStack):
      error, called at libraries/ghc-internal/src/GHC/Internal/List.hs:1689:14 in ghc-internal:GHC.Internal.List
      tooLarge, called at libraries/ghc-internal/src/GHC/Internal/List.hs:1699:50 in ghc-internal:GHC.Internal.List
      !!, called at src-ghc/Clash/GHC/Evaluator/Primitive.hs:3833:61 in clash-ghc-1.9.0-inplace:Clash.GHC.Evaluator.Primitive

when compiling with --verilog.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions