diff --git a/src/bin/expect_tests/michelson_or_tests.ml b/src/bin/expect_tests/michelson_or_tests.ml index 2656620c9..595a76c5e 100644 --- a/src/bin/expect_tests/michelson_or_tests.ml +++ b/src/bin/expect_tests/michelson_or_tests.ml @@ -17,7 +17,7 @@ let%expect_test _ = run_ligo_good [ "compile-contract" ; contract "michelson_or_tree.mligo" ; "main" ] ; [%expect {| { parameter unit ; - storage (or (int %m_left) (or %m_right (int %m_left) (nat %m_right))) ; + storage (or int (or int nat)) ; code { PUSH int 1 ; LEFT nat ; RIGHT int ; diff --git a/src/passes/10-transpiler/transpiler.ml b/src/passes/10-transpiler/transpiler.ml index f2ddbcd9b..121764b82 100644 --- a/src/passes/10-transpiler/transpiler.ml +++ b/src/passes/10-transpiler/transpiler.ml @@ -163,6 +163,7 @@ let rec transpile_type (t:AST.type_expression) : type_value result = ) (* TODO hmm *) | T_sum m -> + let is_michelson_or = Stage_common.Helpers.is_michelson_or m in let node = Append_tree.of_list @@ kv_list_of_cmap m in let aux a b : type_value annotated result = let%bind a = a in @@ -172,7 +173,12 @@ let rec transpile_type (t:AST.type_expression) : type_value result = let%bind m' = Append_tree.fold_ne (fun (Stage_common.Types.Constructor ann, a) -> let%bind a = transpile_type a in - ok (Some (String.uncapitalize_ascii ann), a)) + ok (( + if is_michelson_or then + None + else + Some (String.uncapitalize_ascii ann)), + a)) aux node in ok @@ snd m' | T_record m -> diff --git a/src/stages/common/helpers.ml b/src/stages/common/helpers.ml index 91cd0eae1..3a7c387de 100644 --- a/src/stages/common/helpers.ml +++ b/src/stages/common/helpers.ml @@ -66,3 +66,8 @@ let kv_list_of_record_or_tuple (m: _ LMap.t) = tuple_of_record m else List.rev @@ LMap.to_kv_list m + +let is_michelson_or (t: _ constructor_map) = + CMap.cardinal t = 2 && + (CMap.mem (Constructor "M_left") t) && + (CMap.mem (Constructor "M_right") t) diff --git a/src/stages/common/helpers.mli b/src/stages/common/helpers.mli index 1292bb807..6b8dd6e2f 100644 --- a/src/stages/common/helpers.mli +++ b/src/stages/common/helpers.mli @@ -24,7 +24,7 @@ val get_pair : val tuple_of_record : 'a LMap.t -> (label * 'a) list val list_of_record_or_tuple : 'a LMap.t -> 'a list val kv_list_of_record_or_tuple : 'a LMap.t -> (label * 'a) list - +val is_michelson_or : 'a Types.constructor_map -> bool val bind_map_lmapi :