@@ -154,14 +154,15 @@ expression (L span expr) =
154154 return $ function [] (stmts ++ [ ReturnStmt () (Just exp) ]) `call` []
155155
156156 MultiIf branches ->
157− do branches' <- forM branches $ \(b,e) -> (,) <$> expression b <*> expression e
158− return $ case last branches of
159− (L _ (Var "Basics.otherwise"), e) -> ifs (init branches') (snd (last branches'))
160− _ -> ifs branches'
161− (obj "_E.If" `call` [ ref "$moduleName", string (show span) ])
162− where
163− ifs branches finally = foldr iff finally branches
164− iff (if', then') else' = CondExpr () if' then' else'
157+ do branches' <- forM branches $ \(b,e) -> (,) <$> expression b <*> expression e
158+ return $ case last branches of
159+ (L _ (Var "Basics.otherwise"), _) -> safeIfs branches'
160+ (L _ (Literal (Boolean True)), _) -> safeIfs branches'
161+ _ -> ifs branches' (obj "_E.If" `call` [ ref "$moduleName", string (show span) ])
162+ where
163+ safeIfs branches = ifs (init branches) (snd (last branches))
164+ ifs branches finally = foldr iff finally branches
165+ iff (if', then') else' = CondExpr () if' then' else'
165166
166167 Case e cases ->
167168 do (tempVar,initialMatch) <- Case.toMatch cases