Add an empty let before starting normalization.
[matthijs/master-project/cλash.git] / Normalize.hs
index 93e89b615a0b493ef8a64ebdb99d9029f7ec5f15..57af9125b0195c5194065f041e5c3a71dc77b634 100644 (file)
@@ -442,6 +442,10 @@ normalizeBind bndr = do
       expr_maybe <- getGlobalBind bndr
       case expr_maybe of 
         Just expr -> do
+          -- Introduce an empty Let at the top level, so there will always be
+          -- a let in the expression (none of the transformations will remove
+          -- the last let).
+          let expr' = Let (Rec []) expr
           -- Normalize this expression
           trace ("Transforming " ++ (show bndr) ++ "\nBefore:\n\n" ++ showSDoc ( ppr expr ) ++ "\n") $ return ()
           expr' <- dotransforms transforms expr