on master help sign in
Fix problems generating functions with 10 or more arguments
6237418Evan Czaplicki
compiler/Generate/JavaScript.hs+6−3
@@ -191,11 +191,14 @@ instance ToJS (Expr t v) where
191 Record fs -> makeRecord fs
191 Record fs -> makeRecord fs
192 Binop op e1 e2 -> binop op e1 e2
192 Binop op e1 e2 -> binop op e1 e2
193
193
194− Lambda p e@(L s _) -> liftM (fastFunc . ret) (toJS' body)
194+ Lambda p e@(L s _) -> liftM fastFunc (toJS' body)
195 where
195 where
196 fastFunc body
196 fastFunc body
197− | length args < 2 || length args > 9 = foldr jsFunc body args
197+ | length args < 2 || length args > 9 =
198+ foldr (\arg bod -> jsFunc arg (ret bod)) body args
199+ | otherwise =
198− | otherwise = "F" ++ show (length args) ++ parens (jsFunc (commaSep args) body)
200+ "F" ++ show (length args) ++ parens (jsFunc (commaSep args) (ret body))
201+
199 (args, body) = first reverse $ foldr depattern ([], innerBody) (zip patterns [1..])
202 (args, body) = first reverse $ foldr depattern ([], innerBody) (zip patterns [1..])
200
203
201 depattern (pattern,n) (args, body) =
204 depattern (pattern,n) (args, body) =