git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
TCO does not close over arguments to higher order functions
commit0a607a51a5a939aadd2afa8367e0e67c70150a40 authorPhil Freeman <paf31@cantab.net> dateThu 29 May 2014, 11:07 (12 years ago) parentb25517e
1 file changed+5−2
src/Language/PureScript/Optimizer/TCO.hs+5−2
src/Language/PureScript/Optimizer/TCO.hs+5−2
@@ -95,6 +95,9 @@ tco' = everywhereOnJS convert
9595 collectSelfCallArgs allArgumentValues (JSApp fn args') = collectSelfCallArgs (args' : allArgumentValues) fn
9696 collectSelfCallArgs allArgumentValues _ = allArgumentValues
9797 isSelfCall :: String -> JS -> Bool
98− isSelfCall ident (JSApp (JSVar ident') _) | ident == ident' = True
99− isSelfCall ident (JSApp fn _) = isSelfCall ident fn
98+ isSelfCall ident (JSApp (JSVar ident') args) | ident == ident' && not (any isFunction args) = True
99+ isSelfCall ident (JSApp fn args) | not (any isFunction args) = isSelfCall ident fn
100100 isSelfCall _ _ = False
101+ isFunction :: JS -> Bool
102+ isFunction (JSFunction _ _ _) = True
103+ isFunction _ = False