git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
More unsafePartial fixes
commite81ea12e8e1dc83d2403c1495479d03489858c1c authorAndy Arvanitis <andyarvanitis@gmail.com> dateThu 11 Jul 2019, 17:56 (7 years ago) parentc506359
3 files changed+4−3
src/CodeGen/IL/Common.hs+1−1 src/CodeGen/IL/Optimizer/Inliner.hs+2−2 src/CodeGen/IL/Printer.hs+1
src/CodeGen/IL/Common.hs+1−1
@@ -33,7 +33,7 @@ moduleNameToIL' name =
3333identToIL :: Ident -> Text
3434identToIL UnusedIdent = unusedName
3535identToIL (Ident "$__unused") = unusedName
36−identToIL (Ident name) | name == C.undefined = undefinedName
36+identToIL (Ident name) | name == C.undefined = undefinedName -- Note: done in Printer.hs too
3737identToIL (Ident name) = properToIL name
3838identToIL (GenIdent _ _) = internalError "GenIdent in identToIL"
3939
src/CodeGen/IL/Optimizer/Inliner.hs+2−2
@@ -269,9 +269,9 @@ inlineUnsafeCoerce = everywhereTopDown convert where
269269
270270inlineUnsafePartial :: AST -> AST
271271inlineUnsafePartial = everywhereTopDown convert where
272− convert (App ss fn [ (Function _ Nothing _ (Block _ [Return _ (App _ f' [_])])) ])
272+ convert (App ss fn [ comp ])
273273 | isDict fnUnsafePartial fn
274− = App ss f' [ Var ss undefinedName ]
274+ = App ss comp []
275275 where
276276 fnUnsafePartial :: forall a b. (IsString a, IsString b) => (a, b)
277277 fnUnsafePartial = (C.partialUnsafe, C.unsafePartial)
src/CodeGen/IL/Printer.hs+1
@@ -72,6 +72,7 @@ literals = mkPattern' match'
7272 , currentIndent
7373 , return $ emit "}"
7474 ]
75+ match (Var _ ident) | ident == C.undefined = return $ emit undefinedName
7576 match (Var _ ident) = return $ emit ident
7677 match (VariableIntroduction _ ident value) = mconcat <$> sequence
7778 [ return . emit $ varDecl <> " " <> ident <> " " <> anyType