From 84c2433aef0b3c2d3b8a9106d8c4f0e02891f4ed Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Sat, 21 Mar 2015 14:23:35 +0100 Subject: Avoid segfault from code extracted to ghc. (Fix for bug #1257) --- plugins/extraction/haskell.ml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/extraction/haskell.ml b/plugins/extraction/haskell.ml index 3e5a90efe..52459f78e 100644 --- a/plugins/extraction/haskell.ml +++ b/plugins/extraction/haskell.ml @@ -26,7 +26,7 @@ let pr_upper_id id = str (String.capitalize (Id.to_string id)) let keywords = List.fold_right (fun s -> Id.Set.add (Id.of_string s)) - [ "case"; "class"; "data"; "default"; "deriving"; "do"; "else"; + [ "Any"; "case"; "class"; "data"; "default"; "deriving"; "do"; "else"; "if"; "import"; "in"; "infix"; "infixl"; "infixr"; "instance"; "let"; "module"; "newtype"; "of"; "then"; "type"; "where"; "_"; "__"; "as"; "qualified"; "hiding" ; "unit" ; "unsafeCoerce" ] @@ -56,11 +56,14 @@ let preamble mod_name comment used_modules usf = else str "\ \n#ifdef __GLASGOW_HASKELL__\ \nimport qualified GHC.Base\ +\nimport qualified GHC.Prim\ +\ntype Any = GHC.Prim.Any\ \nunsafeCoerce :: a -> b\ \nunsafeCoerce = GHC.Base.unsafeCoerce#\ \n#else\ \n-- HUGS\ \nimport qualified IOExts\ +\ntype Any = ()\ \nunsafeCoerce :: a -> b\ \nunsafeCoerce = IOExts.unsafeCoerce\ \n#endif" ++ fnl2 ()) @@ -102,7 +105,7 @@ let rec pp_type par vl t = pp_par par (pp_rec true t1 ++ spc () ++ str "->" ++ spc () ++ pp_rec false t2) | Tdummy _ -> str "()" - | Tunknown -> str "()" + | Tunknown -> str "Any" | Taxiom -> str "() -- AXIOM TO BE REALIZED\n" in hov 0 (pp_rec par t) -- cgit v1.2.3