From caf6fe480a38ab17c5d4abe14a6156f83a509c24 Mon Sep 17 00:00:00 2001 From: Evan Czaplicki Date: Thu, 20 Mar 2014 12:46:28 -0700 Subject: [PATCH] Fix #527 When language-ecmascript upgraded from 0.15 to 0.16 they added more validation of what values are valid variables. This adds in protections to make sure that qualified variables like List.map generate valid JavaScript. --- compiler/Generate/JavaScript.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/Generate/JavaScript.hs b/compiler/Generate/JavaScript.hs index 15f1a96..9ff0ed0 100644 --- a/compiler/Generate/JavaScript.hs +++ b/compiler/Generate/JavaScript.hs @@ -55,7 +55,7 @@ literal lit = expression :: Expr -> State Int (Expression ()) expression (A region expr) = case expr of - Var (V.Raw x) -> return $ ref x + Var (V.Raw x) -> return $ obj x Literal lit -> return $ literal lit Range lo hi -> @@ -243,7 +243,11 @@ match region mtch = isLiteral p = case p of Case.Clause (Right _) _ _ -> True _ -> False - access name = if any isLiteral clauses then ref name else dotSep [name,"ctor"] + + access name + | any isLiteral clauses = obj name + | otherwise = dotSep (split name ++ ["ctor"]) + format isChars e | or isChars = InfixExpr () OpAdd e (string "") | otherwise = e