Merge branch 'less-annotations' into 'dev'
Less annotations See merge request ligolang/ligo!566
This commit is contained in:
commit
1f0491e367
@ -10,7 +10,7 @@ let%expect_test _ =
|
||||
[%expect {| 1872 bytes |}] ;
|
||||
|
||||
run_ligo_good [ "measure-contract" ; contract "multisig.ligo" ; "main" ] ;
|
||||
[%expect {| 1294 bytes |}] ;
|
||||
[%expect {| 1282 bytes |}] ;
|
||||
|
||||
run_ligo_good [ "measure-contract" ; contract "multisig-v2.ligo" ; "main" ] ;
|
||||
[%expect {| 2974 bytes |}] ;
|
||||
@ -297,7 +297,7 @@ let%expect_test _ =
|
||||
[%expect {|
|
||||
{ parameter
|
||||
(pair (pair (nat %counter) (lambda %message unit (list operation)))
|
||||
(list %signatures (pair (key_hash %0) (signature %1)))) ;
|
||||
(list %signatures (pair key_hash signature))) ;
|
||||
storage
|
||||
(pair (pair (list %auth key) (nat %counter)) (pair (string %id) (nat %threshold))) ;
|
||||
code { DUP ;
|
||||
@ -1173,7 +1173,20 @@ ligo: in file "create_contract_var.mligo", line 6, character 35 to line 10, char
|
||||
CONS ;
|
||||
DIP { DIP { DUP } ; SWAP ; CDR } ;
|
||||
PAIR ;
|
||||
DIP { DROP 2 } } } |}]
|
||||
DIP { DROP 2 } } } |}];
|
||||
|
||||
run_ligo_good [ "compile-contract" ; contract "tuples_no_annotation.religo" ; "main" ] ;
|
||||
[%expect {|
|
||||
{ parameter int ;
|
||||
storage (pair (pair int string) (pair nat bool)) ;
|
||||
code { PUSH string "2" ;
|
||||
PUSH int 2 ;
|
||||
PAIR ;
|
||||
DIP { PUSH bool False ; PUSH nat 2 ; PAIR } ;
|
||||
PAIR ;
|
||||
NIL operation ;
|
||||
PAIR ;
|
||||
DIP { DROP } } } |}]
|
||||
|
||||
let%expect_test _ =
|
||||
run_ligo_bad [ "compile-contract" ; bad_contract "self_type_annotation.ligo" ; "main" ] ;
|
||||
|
@ -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 ;
|
||||
|
@ -278,6 +278,7 @@ let rec transpile_type (t:AST.type_expression) : type_value result =
|
||||
)
|
||||
(* TODO hmm *)
|
||||
| T_sum m ->
|
||||
let is_michelson_or = Ast_typed.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
|
||||
@ -287,11 +288,23 @@ let rec transpile_type (t:AST.type_expression) : type_value result =
|
||||
let%bind m' = Append_tree.fold_ne
|
||||
(fun (Ast_typed.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 ->
|
||||
let node = Append_tree.of_list @@ Ast_typed.Helpers.kv_list_of_record_or_tuple m in
|
||||
let is_tuple_lmap = Ast_typed.Helpers.is_tuple_lmap m in
|
||||
let node = Append_tree.of_list @@ (
|
||||
if is_tuple_lmap then
|
||||
Ast_typed.Helpers.tuple_of_record m
|
||||
else
|
||||
List.rev @@ Ast_typed.Types.LMap.to_kv_list m
|
||||
)
|
||||
in
|
||||
let aux a b : type_value annotated result =
|
||||
let%bind a = a in
|
||||
let%bind b = b in
|
||||
@ -300,7 +313,12 @@ let rec transpile_type (t:AST.type_expression) : type_value result =
|
||||
let%bind m' = Append_tree.fold_ne
|
||||
(fun (Ast_typed.Types.Label ann, a) ->
|
||||
let%bind a = transpile_type a in
|
||||
ok (Some ann, a))
|
||||
ok ((if is_tuple_lmap then
|
||||
None
|
||||
else
|
||||
Some ann),
|
||||
a)
|
||||
)
|
||||
aux node in
|
||||
ok @@ snd m'
|
||||
| T_arrow {type1;type2} -> (
|
||||
|
@ -163,3 +163,9 @@ 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)
|
@ -66,3 +66,4 @@ let kv_list_of_record_or_tuple (m: _ LMap.t) =
|
||||
tuple_of_record m
|
||||
else
|
||||
List.rev @@ LMap.to_kv_list m
|
||||
|
||||
|
@ -26,7 +26,6 @@ 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 bind_map_lmapi :
|
||||
(Types.label -> 'a -> ('b * 'c list, 'd) result) ->
|
||||
'a Types.label_map -> ('b Types.label_map * 'c list, 'd) result
|
||||
|
7
src/test/contracts/tuples_no_annotation.religo
Normal file
7
src/test/contracts/tuples_no_annotation.religo
Normal file
@ -0,0 +1,7 @@
|
||||
type storage = (int, string, nat, bool)
|
||||
|
||||
type parameter = int
|
||||
|
||||
let main = ((p,storage): (parameter, storage)) => {
|
||||
([]: list (operation), (2, "2", 2n, false));
|
||||
};
|
Loading…
Reference in New Issue
Block a user