on master help sign in
Fix problems generating functions with 10 or more arguments

Mainly useful for record constructors which are automatically generated.

commit623741877b3f5cfab1404acb1da42969a3ecc611 authorEvan Czaplicki <info@elm-lang.org> dateThu 8 Aug 2013, 16:04 (13 years ago) parent143547e
1 file changed+6−3
compiler/Generate/JavaScript.hs+6−3
compiler/Generate/JavaScript.hs+6−3
@@ -191,11 +191,14 @@ instance ToJS (Expr t v) where
191191 Record fs -> makeRecord fs
192192 Binop op e1 e2 -> binop op e1 e2
193193
194− Lambda p e@(L s _) -> liftM (fastFunc . ret) (toJS' body)
194+ Lambda p e@(L s _) -> liftM fastFunc (toJS' body)
195195 where
196196 fastFunc body
197− | length args < 2 || length args > 9 = foldr jsFunc body args
198− | otherwise = "F" ++ show (length args) ++ parens (jsFunc (commaSep args) body)
197+ | length args < 2 || length args > 9 =
198+ foldr (\arg bod -> jsFunc arg (ret bod)) body args
199+ | otherwise =
200+ "F" ++ show (length args) ++ parens (jsFunc (commaSep args) (ret body))
201+
199202 (args, body) = first reverse $ foldr depattern ([], innerBody) (zip patterns [1..])
200203
201204 depattern (pattern,n) (args, body) =