From 5a33eab7bc05f45cde76253f84e139b2428fbbe7 Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Mon, 29 Jan 2018 14:37:59 +0000 Subject: Fix a bug where structs containing unions would generate bad to_string functions Added a regression test in test/ocaml/string_of_struct --- src/ocaml_backend.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ocaml_backend.ml b/src/ocaml_backend.ml index 96dfd9d3..c535554b 100644 --- a/src/ocaml_backend.ml +++ b/src/ocaml_backend.ml @@ -528,7 +528,7 @@ let ocaml_string_of_enum ctx id ids = let ocaml_string_of_struct ctx id typq fields = let arg = gensym () in let ocaml_field (typ, id) = - separate space [string (string_of_id id ^ " = \""); string "^"; ocaml_string_typ typ arg ^^ string "." ^^ zencode ctx id] + separate space [string (string_of_id id ^ " = \""); string "^"; ocaml_string_typ typ (arg ^^ string "." ^^ zencode ctx id)] in separate space [string "let"; ocaml_string_of id; parens (arg ^^ space ^^ colon ^^ space ^^ zencode ctx id); equals] ^//^ (string "\"{" ^^ separate_map (hardline ^^ string "^ \", ") ocaml_field fields ^^ string " ^ \"}\"") -- cgit v1.2.3