git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix for issue #53: record updates need dict copy
commitcd83d8c93b0c3af33d7a17d7be1f8864fd590776 authorAndy Arvanitis <andyarvanitis@gmail.com> dateMon 27 Jul 2020, 18:48 (6 years ago) parentd22d458
2 files changed+8−1
src/CodeGen/IL.hs+4−1 src/CodeGen/IL/Common.hs+4
src/CodeGen/IL.hs+4−1
@@ -180,7 +180,7 @@ moduleToIL (Module _ coms mn _ imps _ foreigns decls) project =
180180 updates <- mapM (sndM valueToIL) ps
181181 obj' <- freshName'
182182 let objVar = AST.Var Nothing obj'
183− copy = AST.VariableIntroduction Nothing obj' (Just $ AST.App Nothing (AST.StringLiteral Nothing (mkString dictType)) [obj])
183+ copy = AST.VariableIntroduction Nothing obj' (Just $ copyDict obj)
184184 assign (k, v) = AST.Assignment Nothing (accessorString k objVar) v
185185 sts = copy : (assign <$> updates) ++ [AST.Return Nothing objVar]
186186 return $ AST.App Nothing (AST.Function Nothing Nothing [] (AST.Block Nothing sts)) []
@@ -359,3 +359,6 @@ emptyAnn = (SourceSpan "" (SourcePos 0 0) (SourcePos 0 0), [], Nothing, Nothing)
359359arrayLength :: AST -> AST
360360arrayLength a = AST.App Nothing (AST.Var Nothing arrayLengthFn) [a]
361361-- arrayLength a = AST.Var Nothing (arrayLengthFn <> "(" <> prettyPrintIL1 a <> ")")
362+
363+copyDict :: AST -> AST
364+copyDict a = AST.App Nothing (AST.Var Nothing copyDictFn) [a]
src/CodeGen/IL/Common.hs+4
@@ -76,6 +76,7 @@ nameIsILBuiltIn name =
7676 [ "Any"
7777 , "Apply"
7878 , "Contains"
79+ , "CopyDict"
7980 , "Dict"
8081 , "EffFn"
8182 , "Fn"
@@ -188,6 +189,9 @@ arrayLengthFn = "Length"
188189indexFn :: Text
189190indexFn = "Index"
190191
192+copyDictFn :: Text
193+copyDictFn = "CopyDict"
194+
191195freshName' :: MonadSupply m => m Text
192196freshName' = do
193197 name <- freshName