git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #414 from purescript/bettertco

Expand one of the inliner rules to enable better TCO

commit6e6980cac31ce24b7b388a725e78979355302893 authorPhil Freeman <paf31@cantab.net> dateMon 12 May 2014, 16:14 (12 years ago) parent797dfa00bc8ddd
1 file changed+5−1
src/Language/PureScript/Optimizer/Inliner.hs+5−1
src/Language/PureScript/Optimizer/Inliner.hs+5−1
@@ -53,7 +53,11 @@ unThunk :: JS -> JS
5353unThunk = everywhereOnJS convert
5454 where
5555 convert :: JS -> JS
56− convert (JSBlock [JSReturn (JSApp (JSFunction Nothing [] (JSBlock body)) [])]) = JSBlock body
56+ convert (JSBlock []) = JSBlock []
57+ convert (JSBlock jss) =
58+ case (last jss) of
59+ JSReturn (JSApp (JSFunction Nothing [] (JSBlock body)) []) -> JSBlock $ init jss ++ body
60+ _ -> JSBlock jss
5761 convert js = js
5862
5963evaluateIifes :: JS -> JS