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.
This commit is contained in:
Evan Czaplicki 2014-03-20 12:46:28 -07:00
parent 3b3ee156f2
commit caf6fe480a

View file

@ -55,7 +55,7 @@ literal lit =
expression :: Expr -> State Int (Expression ()) expression :: Expr -> State Int (Expression ())
expression (A region expr) = expression (A region expr) =
case expr of case expr of
Var (V.Raw x) -> return $ ref x Var (V.Raw x) -> return $ obj x
Literal lit -> return $ literal lit Literal lit -> return $ literal lit
Range lo hi -> Range lo hi ->
@ -243,7 +243,11 @@ match region mtch =
isLiteral p = case p of isLiteral p = case p of
Case.Clause (Right _) _ _ -> True Case.Clause (Right _) _ _ -> True
_ -> False _ -> 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 format isChars e
| or isChars = InfixExpr () OpAdd e (string "") | or isChars = InfixExpr () OpAdd e (string "")
| otherwise = e | otherwise = e