From d947c778e6e6e95e896cfc6926a4fdf12f16806d Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 6 Aug 2009 19:19:52 +0200 Subject: [PATCH] Filter out empty-typed binders in selector cases. This makes sure that the non-empty binders are skipped when calculating the field number, which prevents overflow when indexing the field names. --- "c\316\273ash/CLasH/VHDL/Generate.hs" | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git "a/c\316\273ash/CLasH/VHDL/Generate.hs" "b/c\316\273ash/CLasH/VHDL/Generate.hs" index 827315c..5386e7e 100644 --- "a/c\316\273ash/CLasH/VHDL/Generate.hs" +++ "b/c\316\273ash/CLasH/VHDL/Generate.hs" @@ -166,7 +166,8 @@ mkConcSm (bndr, expr@(CoreSyn.Case (CoreSyn.Var scrut) b ty [alt])) | otherwise = case alt of (CoreSyn.DataAlt dc, bndrs, (CoreSyn.Var sel_bndr)) -> do - case List.elemIndex sel_bndr bndrs of + bndrs' <- Monad.filterM hasNonEmptyType bndrs + case List.elemIndex sel_bndr bndrs' of Just i -> do labels <- MonadState.lift tsType $ getFieldLabels (Id.idType scrut) let label = labels!!i -- 2.30.2