@@ -170,8 +170,16 @@ compileJS (JSIndex lhs rhs) =
170 compileJS lhs ++ "[" ++ compileJS rhs ++ "]"
170 compileJS lhs ++ "[" ++ compileJS rhs ++ "]"
172compileJS (JSCond branches) =
172compileJS (JSCond branches) =
173− intercalate " else " $ map createIfBlock branches
173+ intercalate " else " $ map createIfBlock (eliminateDeadBranches branches)
175+ eliminateDeadBranches (e@(JSTrue, _):_) = [e]
176+ eliminateDeadBranches (x:xs) = x : eliminateDeadBranches xs
177+ eliminateDeadBranches [] = []
179+ createIfBlock (JSTrue, e) =
181+ ++ "return " ++ compileJS e
175 createIfBlock (cond, e) =
183 createIfBlock (cond, e) =
176 "if (" ++ compileJS cond ++") {\n"
184 "if (" ++ compileJS cond ++") {\n"
177 ++ "return " ++ compileJS e
185 ++ "return " ++ compileJS e