@@ -480,6 +480,11 @@ reduceJS js = reduceLoop [] ([], js)
480480funName :: JS -> String
481481funName (JSAlloc fun _) = fun
482482
483+elimDeadLoop :: [JS] -> [JS]
484+elimDeadLoop js
485+ | ret <- deadEvalApplyCases js
486+ , ret /= js = elimDeadLoop ret
487+ | otherwise = js
483488
484489deadEvalApplyCases :: [JS] -> [JS]
485490deadEvalApplyCases js =
@@ -942,7 +947,7 @@ codegenJavaScript target definitions filename outputType = do
942947 constRemoved = map reduceConstants reduced
943948 constrInit = initConstructors constRemoved
944949 removeAlloc = map removeAllocations constrInit
945− deadElim = deadEvalApplyCases removeAlloc
950+ deadElim = elimDeadLoop removeAlloc
946951 js = inlineFunctions deadElim in
947952 map compileJS js
948953