Filter out empty-typed binders in selector cases.
[matthijs/master-project/cλash.git] / cλash / CLasH / VHDL / Generate.hs
index 827315cfd70ee9f7e6aa2ca9c5c1671ce200477b..5386e7e61b698a0681830ffc9b4b14c2c9c1e67f 100644 (file)
@@ -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