diff --git a/lib/ligo_lltz_codgen/ligo_lltz_codegen.ml b/lib/ligo_lltz_codgen/ligo_lltz_codegen.ml index e3ba33b1e..508fd8392 100644 --- a/lib/ligo_lltz_codgen/ligo_lltz_codegen.ml +++ b/lib/ligo_lltz_codgen/ligo_lltz_codegen.ml @@ -47,7 +47,13 @@ let rec compile_type_expression (type_ : I.type_expression) : O.Type.t = | T_sapling_transaction memo -> return @@ Sapling_transaction { memo = Z.to_int memo } | T_function (arg_type, ret_type) -> return @@ Function (compile_type_expression arg_type, compile_type_expression ret_type) - | T_tuple annot_types -> return @@ Tuple (compile_row annot_types) + | T_tuple annot_types -> + (match annot_types with + | [] -> assert false + | [ (_annot, el) ] -> + (* TODO: should this handled by LLTZ? *) + compile_type_expression el + | annot_types -> return @@ Tuple (compile_row annot_types)) | T_or (left, right) -> return @@ Or (compile_row [ left; right ]) | T_base TB_unit -> return Unit | T_base TB_bool -> return Bool @@ -557,16 +563,30 @@ let rec compile_expression (expr : I.expression) : O.Expr.t = let var, body = compile_binders binders ~in_:(compile_expression body) in return @@ For_each { collection; body = { lam_var = var; body } } | E_tuple elts -> - let elts = List.map elts ~f:compile_expression in - let row = O.Row.(Node (List.map elts ~f:(fun elt -> Leaf (None, elt)))) in - return @@ Tuple row - | E_proj (tuple, index, _tuple_size) -> - let tuple = compile_expression tuple in - return @@ Proj (tuple, O.Row.Path.Here [ index ]) - | E_update (tuple, index, update, _tuple_size) -> - let tuple = compile_expression tuple in - let update = compile_expression update in - return @@ Update { tuple; component = O.Row.Path.Here [ index ]; update } + (match elts with + | [] -> assert false + | [ elt ] -> compile_expression elt + | elts -> + let elts = List.map elts ~f:compile_expression in + let row = O.Row.(Node (List.map elts ~f:(fun elt -> Leaf (None, elt)))) in + return @@ Tuple row) + | E_proj (tuple, index, tuple_size) -> + (match tuple_size with + | 0 -> assert false + | 1 -> + assert (index = 0); + compile_expression tuple + | _ -> + let tuple = compile_expression tuple in + return @@ Proj (tuple, O.Row.Path.Here [ index ])) + | E_update (tuple, index, update, tuple_size) -> + (match tuple_size with + | 0 -> assert false + | 1 -> compile_expression update + | _ -> + let tuple = compile_expression tuple in + let update = compile_expression update in + return @@ Update { tuple; component = O.Row.Path.Here [ index ]; update }) | E_let_tuple (rhs, (binders, in_)) -> let components = List.map (List.map binders ~f:compile_binder) ~f:fst in let rhs = compile_expression rhs in diff --git a/src/bin/expect_tests/aggregation.ml b/src/bin/expect_tests/aggregation.ml index 17a52232b..a7c146307 100644 --- a/src/bin/expect_tests/aggregation.ml +++ b/src/bin/expect_tests/aggregation.ml @@ -19,12 +19,13 @@ let%expect_test _ = storage unit ; code { DROP ; PUSH nat 1 ; - PUSH nat 1 ; + DUP ; ADD ; PUSH nat 2 ; COMPARE ; EQ ; - IF { UNIT } { PUSH string "failed assertion" ; FAILWITH } ; + IF {} { PUSH string "failed assertion" ; FAILWITH } ; + UNIT ; NIL operation ; PAIR } } |}] @@ -32,9 +33,7 @@ let%expect_test _ = run_ligo_good [ "compile"; "contract"; contract "effects.mligo" ]; [%expect {| - { parameter int ; - storage int ; - code { CDR ; PUSH string "foo" ; FAILWITH } } |}] + { parameter int ; storage int ; code { PUSH string "foo" ; FAILWITH } } |}] let%expect_test _ = run_ligo_good diff --git a/src/bin/expect_tests/annotated_michelson_record.ml b/src/bin/expect_tests/annotated_michelson_record.ml index a444458da..20a3f05bb 100644 --- a/src/bin/expect_tests/annotated_michelson_record.ml +++ b/src/bin/expect_tests/annotated_michelson_record.ml @@ -26,7 +26,7 @@ let%expect_test _ = [%expect {| { parameter unit ; - storage (pair (int %ana) (string %anb) (nat %anc)) ; + storage (pair (int %ana) (pair (string %anb) (nat %anc))) ; code { DROP ; PUSH nat 1 ; PUSH string "" ; @@ -45,7 +45,8 @@ let%expect_test _ = {| { parameter unit ; storage - (pair (int %an_One) (string %an_Two) (bool %an_Three) (nat %an_Four) (int %an_Five)) ; + (pair (int %an_One) + (pair (string %an_Two) (pair (bool %an_Three) (pair (nat %an_Four) (int %an_Five))))) ; code { CDR ; NIL operation ; PAIR } } |}] let%expect_test _ = @@ -127,7 +128,7 @@ let%expect_test _ = {| { parameter unit ; storage - (pair (pair (pair (int %an_Five) (nat %an_Four)) (int %an_One) (bool %an_Three)) + (pair (pair (pair (int %an_Five) (nat %an_Four)) (pair (int %an_One) (bool %an_Three))) (string %an_Two)) ; code { CDR ; NIL operation ; PAIR } } |}] diff --git a/src/bin/expect_tests/build_module_test.ml b/src/bin/expect_tests/build_module_test.ml index 42d872824..804c438e7 100644 --- a/src/bin/expect_tests/build_module_test.ml +++ b/src/bin/expect_tests/build_module_test.ml @@ -90,15 +90,7 @@ let%expect_test _ = {| { parameter int ; storage int ; - code { PUSH int 1 ; - PUSH int 10 ; - ADD ; - SWAP ; - UNPAIR ; - ADD ; - ADD ; - NIL operation ; - PAIR } } |}] + code { PUSH int 11 ; SWAP ; UNPAIR ; ADD ; ADD ; NIL operation ; PAIR } } |}] let%expect_test _ = run_ligo_good [ "compile"; "contract"; contract "instance/main.mligo" ]; @@ -122,15 +114,7 @@ let%expect_test _ = {| { parameter int ; storage int ; - code { PUSH int 1 ; - PUSH int 10 ; - ADD ; - SWAP ; - UNPAIR ; - ADD ; - ADD ; - NIL operation ; - PAIR } } |}] + code { PUSH int 11 ; SWAP ; UNPAIR ; ADD ; ADD ; NIL operation ; PAIR } } |}] let%expect_test _ = run_ligo_bad [ "print"; "ast-typed"; contract "cycle_A.mligo" ]; diff --git a/src/bin/expect_tests/contract_metadata.ml b/src/bin/expect_tests/contract_metadata.ml index 77d3feebb..566561559 100644 --- a/src/bin/expect_tests/contract_metadata.ml +++ b/src/bin/expect_tests/contract_metadata.ml @@ -493,7 +493,7 @@ let%expect_test _ = Warning: Empty key in metadata big-map is mandatory. (Pair (Pair 42 { Elt "titi" 0x24 ; Elt "toto" 0x42 }) { Elt 0 - 0x050200000047032009310000003b07650765035b076103680369076103620369096500000014055f036d0765035b076103680369076103620369000000000200000006053d036d034200000000 }) |}] + 0x050200000041032009310000003507650765035b0761036803690761036203690765055f036d07650765035b0761036803690761036203690200000006053d036d034200000000 }) |}] (* -------------------------------------------------------------------------- *) (* Contracts with invalid 'metadata' should pass when the waiver flag is enabled *) diff --git a/src/bin/expect_tests/contract_tests.ml b/src/bin/expect_tests/contract_tests.ml index a0f8c6f16..24cded324 100644 --- a/src/bin/expect_tests/contract_tests.ml +++ b/src/bin/expect_tests/contract_tests.ml @@ -12,7 +12,7 @@ let%expect_test _ = [%expect {| { parameter (or (chest %initialize) (or (bytes %guess) (chest_key %finish))) ; - storage (pair (nat %level) (chest %chest) (bytes %guess) (bytes %result)) ; + storage (pair (nat %level) (pair (chest %chest) (pair (bytes %guess) (bytes %result)))) ; code { UNPAIR ; IF_LEFT { SWAP ; DROP ; PUSH bytes 0xa0 ; DUP ; DIG 2 ; LEVEL ; PAIR 4 } @@ -35,7 +35,6 @@ let%expect_test _ = { PUSH bytes 0x10 } { DUP 2 ; GET 5 ; - SWAP ; COMPARE ; EQ ; IF { PUSH bytes 0x00 } { PUSH bytes 0x01 } } ; @@ -248,11 +247,7 @@ let%expect_test _ = ]; [%expect {| - { LAMBDA (pair int int) int { UNPAIR ; ADD } ; - DUP 2 ; - APPLY ; - SWAP ; - DROP } |}] + { LAMBDA (pair int int) int { UNPAIR ; ADD } ; SWAP ; APPLY } |}] let%expect_test _ = run_ligo_good @@ -385,11 +380,11 @@ let%expect_test _ = (pair %request (address %owner) (address %spender)) (contract %callback nat)) (or (pair %approve (address %spender) (nat %value)) - (pair %transfer (address %from) (address %to) (nat %value)))))) ; + (pair %transfer (address %from) (pair (address %to) (nat %value))))))) ; storage (pair (big_map %tokens address nat) - (big_map %allowances (pair (address %owner) (address %spender)) nat) - (nat %total_supply)) ; + (pair (big_map %allowances (pair (address %owner) (address %spender)) nat) + (nat %total_supply))) ; code { UNPAIR ; IF_LEFT { DUP 2 ; @@ -454,9 +449,8 @@ let%expect_test _ = DIG 3 ; CDR ; DIG 3 ; - PUSH nat 0 ; - DUP 3 ; - COMPARE ; + DUP 2 ; + INT ; EQ ; IF { SWAP ; DROP ; NONE nat } { SWAP ; SOME } ; DIG 3 ; @@ -486,9 +480,8 @@ let%expect_test _ = ISNAT ; IF_NONE { PUSH string "NotEnoughAllowance" ; FAILWITH } {} ; DIG 3 ; - PUSH nat 0 ; - DUP 3 ; - COMPARE ; + DUP 2 ; + INT ; EQ ; IF { SWAP ; DROP ; NONE nat } { SWAP ; SOME } ; DIG 2 ; @@ -504,9 +497,8 @@ let%expect_test _ = ISNAT ; IF_NONE { PUSH string "NotEnoughBalance" ; FAILWITH } {} ; DIG 2 ; - PUSH nat 0 ; - DUP 3 ; - COMPARE ; + DUP 2 ; + INT ; EQ ; IF { SWAP ; DROP ; NONE nat } { SWAP ; SOME } ; DUP 4 ; @@ -522,9 +514,8 @@ let%expect_test _ = ADD ; DIG 4 ; DIG 2 ; - PUSH nat 0 ; - DUP 4 ; - COMPARE ; + DUP 3 ; + INT ; EQ ; IF { DIG 2 ; DROP ; NONE nat } { DIG 2 ; SOME } ; DIG 4 ; @@ -561,9 +552,8 @@ let%expect_test _ = SWAP ; ITER { CONS } ; ITER { CONS } ; - SWAP ; NIL int ; - SWAP ; + DIG 2 ; ITER { CONS } ; ITER { CONS } ; NIL operation ; @@ -720,14 +710,12 @@ let%expect_test _ = {| { parameter (or (or %vote (unit %yea) (unit %nay)) - (pair %reset (string %title) (timestamp %start_time) (timestamp %finish_time))) ; + (pair %reset (string %title) (pair (timestamp %start_time) (timestamp %finish_time)))) ; storage (pair (string %title) - (nat %yea) - (nat %nay) - (set %voters address) - (timestamp %start_time) - (timestamp %finish_time)) ; + (pair (nat %yea) + (pair (nat %nay) + (pair (set %voters address) (pair (timestamp %start_time) (timestamp %finish_time)))))) ; code { UNPAIR ; IF_LEFT { SENDER ; @@ -749,7 +737,7 @@ let%expect_test _ = GET 3 ; EMPTY_SET address ; PUSH nat 0 ; - PUSH nat 0 ; + DUP ; DIG 5 ; CAR ; PAIR 6 } ; @@ -762,7 +750,9 @@ let%expect_test _ = {| { parameter (or (ticket %receive unit) - (pair %send (contract %destination (ticket unit)) (nat %amount) (address %ticketer))) ; + (pair %send + (contract %destination (ticket unit)) + (pair (nat %amount) (address %ticketer)))) ; storage (pair (address %manager) (big_map %tickets address (ticket unit))) ; code { UNPAIR ; PUSH mutez 0 ; @@ -804,10 +794,9 @@ let%expect_test _ = GET 4 ; GET_AND_UPDATE ; IF_NONE - { DROP 3 ; PUSH string "no tickets" ; FAILWITH } + { PUSH string "no tickets" ; FAILWITH } { READ_TICKET ; - CDR ; - CDR ; + GET 4 ; DUP 4 ; GET 3 ; DUP ; @@ -820,7 +809,7 @@ let%expect_test _ = SWAP ; SPLIT_TICKET ; IF_NONE - { DROP 3 ; PUSH string "impossible?" ; FAILWITH } + { PUSH string "impossible?" ; FAILWITH } { UNPAIR ; DUG 2 ; SOME ; @@ -869,7 +858,6 @@ let%expect_test _ = DROP ; CAR ; SELF_ADDRESS ; - SWAP ; COMPARE ; EQ ; IF {} { PUSH string "failed assertion" ; FAILWITH } ; @@ -970,10 +958,8 @@ let%expect_test _ = (pair (lambda operation (contract int)) int) (lambda operation (contract int)) { CAR } ; - DUP 2 ; - APPLY ; SWAP ; - DROP } |}] + APPLY } |}] let%expect_test _ = run_ligo_good [ "compile"; "contract"; contract "amount_lambda.mligo" ]; @@ -1028,12 +1014,7 @@ let%expect_test _ = { parameter bool ; storage (lambda unit mutez) ; code { CAR ; - IF { AMOUNT ; - LAMBDA (pair mutez unit) mutez { CAR } ; - DUP 2 ; - APPLY ; - SWAP ; - DROP } + IF { LAMBDA (pair mutez unit) mutez { CAR } ; AMOUNT ; APPLY } { LAMBDA unit mutez { DROP ; AMOUNT } } ; NIL operation ; PAIR } } |}] @@ -1413,7 +1394,7 @@ let%expect_test _ = {| { parameter unit ; storage unit ; - code { LAMBDA (pair unit unit unit unit) unit { DROP ; UNIT } ; + code { LAMBDA (pair unit (pair unit (pair unit unit))) unit { DROP ; UNIT } ; LAMBDA (pair nat nat) nat { UNPAIR ; MUL } ; |}] (* old uncurry bugs: *) @@ -1471,7 +1452,7 @@ let%expect_test _ = Warning: unused variable "s". Hint: replace it by "_s" to prevent this warning. - { parameter (pair (int %x) (int %y) (int %z) (int %w)) ; + { parameter (pair (int %x) (pair (int %y) (pair (int %z) (int %w)))) ; storage int ; code { CAR ; UNPAIR 4 ; ADD ; ADD ; ADD ; NIL operation ; PAIR } } |}] @@ -1631,7 +1612,7 @@ let%expect_test _ = run_ligo_good [ "compile"; "contract"; contract "annotation_cases.mligo"; "-m"; "A" ]; [%expect {| - { parameter (pair (nat %AAA) (nat %fooB) (nat %cCC)) ; + { parameter (pair (nat %AAA) (pair (nat %fooB) (nat %cCC))) ; storage unit ; code { DROP ; UNIT ; NIL operation ; PAIR } } |}] @@ -1776,7 +1757,9 @@ let%expect_test _ = {| { parameter (or (ticket %receive unit) - (pair %send (contract %destination (ticket unit)) (nat %amount) (address %ticketer))) ; + (pair %send + (contract %destination (ticket unit)) + (pair (nat %amount) (address %ticketer)))) ; storage (pair (address %manager) (big_map %tickets address (ticket unit))) ; code { UNPAIR ; PUSH mutez 0 ; @@ -1818,10 +1801,9 @@ let%expect_test _ = GET 4 ; GET_AND_UPDATE ; IF_NONE - { DROP 3 ; PUSH string "no tickets" ; FAILWITH } + { PUSH string "no tickets" ; FAILWITH } { READ_TICKET ; - CDR ; - CDR ; + GET 4 ; DUP 4 ; GET 3 ; DUP ; @@ -1834,7 +1816,7 @@ let%expect_test _ = SWAP ; SPLIT_TICKET ; IF_NONE - { DROP 3 ; PUSH string "impossible?" ; FAILWITH } + { PUSH string "impossible?" ; FAILWITH } { UNPAIR ; DUG 2 ; SOME ; @@ -1869,45 +1851,18 @@ let%expect_test _ = {| { parameter unit ; storage unit ; - code { { /* _ */ } ; - CDR ; - { /* _ */ } ; - { /* File "../../test/contracts/noop.mligo", line 3, character 2 to line 7, character 28 */ - { /* File "../../test/contracts/noop.mligo", line 3, characters 28-29 */ - LAMBDA - unit - unit - { { /* x */ } ; - { /* File "../../test/contracts/noop.mligo", line 3, characters 28-29 */ } } } ; - { /* f, _ */ } ; - { /* File "../../test/contracts/noop.mligo", line 4, character 2 to line 7, character 28 */ - { /* File "../../test/contracts/noop.mligo", line 4, characters 18-21 */ - SWAP ; - { /* File "../../test/contracts/noop.mligo", line 4, characters 18-19 */ DUP 2 } ; - SWAP ; - EXEC } ; - { /* s2, f */ } ; - { /* File "../../test/contracts/noop.mligo", line 5, character 2 to line 7, character 28 */ - { /* File "../../test/contracts/noop.mligo", line 5, characters 18-22 */ - { /* File "../../test/contracts/noop.mligo", line 5, characters 20-22 */ } ; - { /* File "../../test/contracts/noop.mligo", line 5, characters 18-19 */ DUP 2 } ; - SWAP ; - EXEC } ; - { /* s3, f */ } ; - { /* File "../../test/contracts/noop.mligo", line 6, character 2 to line 7, character 28 */ - { /* File "../../test/contracts/noop.mligo", line 6, characters 10-14 */ - { /* File "../../test/contracts/noop.mligo", line 6, characters 12-14 */ } ; - { /* File "../../test/contracts/noop.mligo", line 6, characters 10-11 */ SWAP } ; - SWAP ; - EXEC } ; - { /* s */ } ; - { /* File "../../test/contracts/noop.mligo", line 7, characters 3-27 */ - { /* File "../../test/contracts/noop.mligo", line 7, characters 26-27 */ } ; - { /* File "../../test/contracts/noop.mligo", line 7, characters 3-24 */ - NIL operation - /* File "../../test/contracts/noop.mligo", line 7, characters 3-24 */ - /* File "../../test/contracts/noop.mligo", line 7, characters 3-24 */ } ; - PAIR } } } } } } } |}] + code { CDR ; + LAMBDA unit unit {} ; + SWAP ; + DUP 2 ; + SWAP ; + EXEC ; + DUP 2 ; + SWAP ; + EXEC ; + EXEC ; + NIL operation ; + PAIR } } |}] (* JSON source location comments *) let%expect_test _ = @@ -2230,9 +2185,7 @@ let%expect_test _ = code { LEFT string ; LOOP_LEFT { UNPAIR ; - PUSH int 0 ; - DUP 2 ; - COMPARE ; + DUP ; EQ ; IF { DROP ; RIGHT (pair int string) } { PUSH string "toto" ; @@ -2790,10 +2743,10 @@ let%expect_test _ = {| { parameter (pair (string %name) - (or %planetType - (string %union.Injection_0) - (or (string %union.Injection_1) (string %union.Injection_2))) - (option %lord address)) ; + (pair (or %planetType + (string %union.Injection_0) + (or (string %union.Injection_1) (string %union.Injection_2))) + (option %lord address))) ; storage int ; code { CAR ; PUSH int 0 ; @@ -2808,9 +2761,7 @@ let%expect_test _ = GET 3 ; IF_LEFT { LEFT string ; EXEC ; DROP } - { IF_LEFT - { DROP 2 ; PUSH int 2 ; SWAP ; SUB } - { RIGHT string ; EXEC ; DROP } } ; + { IF_LEFT { DROP 2 ; PUSH int -2 ; ADD } { RIGHT string ; EXEC ; DROP } } ; LAMBDA (or string string) unit { DROP ; UNIT } ; DIG 2 ; GET 3 ; @@ -2825,13 +2776,13 @@ let%expect_test _ = [%expect {| { parameter (or (unit %a) (or (int %b) (pair %c int int))) ; - storage (pair (int %x) (int %y) (int %z)) ; + storage (pair (int %x) (pair (int %y) (int %z))) ; code { CAR ; IF_LEFT - { DROP ; PUSH int 10 ; PUSH int 10 ; PUSH int 10 } - { IF_LEFT - { DROP ; PUSH int 20 ; PUSH int 20 ; PUSH int 20 } - { DROP ; PUSH int 20 ; PUSH int 20 ; PUSH int 20 } } ; + { DROP ; PUSH int 10 } + { IF_LEFT { DROP ; PUSH int 20 } { DROP ; PUSH int 20 } } ; + DUP ; + DUP ; PAIR 3 ; NIL operation ; PAIR } } |}] @@ -2842,16 +2793,7 @@ let%expect_test _ = {| { parameter unit ; storage (list int) ; - code { DROP ; - NIL int ; - PUSH int 3 ; - CONS ; - PUSH int 2 ; - CONS ; - PUSH int 1 ; - CONS ; - NIL operation ; - PAIR } } |}] + code { DROP ; PUSH (list int) { 1 ; 2 ; 3 } ; NIL operation ; PAIR } } |}] let%expect_test _ = run_ligo_good [ "compile"; "contract"; contract "used_var_in_local_module.mligo" ]; @@ -3021,11 +2963,11 @@ let%expect_test _ = (pair %request (address %owner) (address %spender)) (contract %callback nat)) (or (pair %approve (address %spender) (nat %value)) - (pair %transfer (address %from) (address %to) (nat %value)))))) ; + (pair %transfer (address %from) (pair (address %to) (nat %value))))))) ; storage (pair (big_map %tokens address nat) - (big_map %allowances (pair (address %owner) (address %spender)) nat) - (nat %total_supply)) ; + (pair (big_map %allowances (pair (address %owner) (address %spender)) nat) + (nat %total_supply))) ; code { UNPAIR ; IF_LEFT { DUP 2 ; @@ -3090,9 +3032,8 @@ let%expect_test _ = DIG 3 ; CDR ; DIG 3 ; - PUSH nat 0 ; - DUP 3 ; - COMPARE ; + DUP 2 ; + INT ; EQ ; IF { SWAP ; DROP ; NONE nat } { SWAP ; SOME } ; DIG 3 ; @@ -3122,9 +3063,8 @@ let%expect_test _ = ISNAT ; IF_NONE { PUSH string "NotEnoughAllowance" ; FAILWITH } {} ; DIG 3 ; - PUSH nat 0 ; - DUP 3 ; - COMPARE ; + DUP 2 ; + INT ; EQ ; IF { SWAP ; DROP ; NONE nat } { SWAP ; SOME } ; DIG 2 ; @@ -3140,9 +3080,8 @@ let%expect_test _ = ISNAT ; IF_NONE { PUSH string "NotEnoughBalance" ; FAILWITH } {} ; DIG 2 ; - PUSH nat 0 ; - DUP 3 ; - COMPARE ; + DUP 2 ; + INT ; EQ ; IF { SWAP ; DROP ; NONE nat } { SWAP ; SOME } ; DUP 4 ; @@ -3158,9 +3097,8 @@ let%expect_test _ = ADD ; DIG 4 ; DIG 2 ; - PUSH nat 0 ; - DUP 4 ; - COMPARE ; + DUP 3 ; + INT ; EQ ; IF { DIG 2 ; DROP ; NONE nat } { DIG 2 ; SOME } ; DIG 4 ; @@ -3237,8 +3175,7 @@ let%expect_test _ = (or (pair %init address nat) (or (address %pokeAndGetFeedback) (unit %poke))) ; storage (pair (map %pokeTraces address (pair (address %receiver) (string %feedback))) - (string %feedback) - (map %ticketOwnership address (ticket string))) ; + (pair (string %feedback) (map %ticketOwnership address (ticket string)))) ; code { UNPAIR ; IF_LEFT { SWAP ; @@ -3248,7 +3185,7 @@ let%expect_test _ = CDR ; COMPARE ; EQ ; - IF { DIG 3 ; DROP ; DIG 2 } + IF { DIG 3 ; DROP } { DUP 4 ; CDR ; PUSH string "can_poke" ; @@ -3259,8 +3196,8 @@ let%expect_test _ = SOME ; DIG 4 ; CAR ; - UPDATE } ; - DUG 2 ; + UPDATE ; + DUG 2 } ; PAIR 3 ; NIL operation ; PAIR } @@ -3278,24 +3215,18 @@ let%expect_test _ = VIEW "feedback" string ; SWAP ; IF_NONE - { DROP 4 ; - PUSH string "User does not have tickets => not allowed" ; - FAILWITH } + { PUSH string "User does not have tickets => not allowed" ; FAILWITH } { DROP ; IF_NONE - { DROP 3 ; - PUSH string "Cannot find view feedback on given oracle address" ; - FAILWITH } + { PUSH string "Cannot find view feedback on given oracle address" ; FAILWITH } { SWAP ; DUP 2 ; DIG 3 ; DIG 3 ; DIG 4 ; PAIR ; - SOURCE ; - DUG 2 ; SOME ; - DIG 2 ; + SOURCE ; UPDATE ; PAIR 3 ; NIL operation ; @@ -3307,23 +3238,19 @@ let%expect_test _ = SOURCE ; GET_AND_UPDATE ; IF_NONE - { DROP 3 ; - PUSH string "User does not have tickets => not allowed" ; - FAILWITH } + { PUSH string "User does not have tickets => not allowed" ; FAILWITH } { DROP ; DUG 2 ; PUSH string "" ; SELF_ADDRESS ; PAIR ; - SOURCE ; - DUG 2 ; SOME ; - DIG 2 ; + SOURCE ; UPDATE ; PAIR 3 ; NIL operation ; PAIR } } } } ; - view "feedback" unit string { CDR ; GET 3 } } |}] + view "feedback" unit string { GET 5 } } |}] let%expect_test _ = run_ligo_good [ "compile"; "parameter"; contract "pokeGame.jsligo"; "Poke()" ]; @@ -3391,7 +3318,6 @@ let%expect_test _ = PUSH bytes 0x0006 ; LSR ; PUSH bytes 0x0003 ; - SWAP ; COMPARE ; EQ ; PUSH bytes 0x0600 ; @@ -3492,7 +3418,6 @@ let%expect_test _ = DUP ; INT ; BYTES ; - SWAP ; COMPARE ; EQ ; IF {} { PUSH string "failed assertion" ; FAILWITH } ; @@ -3564,7 +3489,7 @@ let%expect_test _ = code { UNPAIR ; IF_LEFT { DROP 2 ; PUSH int 0 } - { IF_LEFT { DROP ; PUSH int 1 ; SWAP ; SUB } { DROP ; PUSH int 1 ; ADD } } ; + { IF_LEFT { DROP ; PUSH int -1 ; ADD } { DROP ; PUSH int 1 ; ADD } } ; NIL operation ; PAIR } } |}]; run_ligo_good [ "run"; "test"; contract "increment_prefix.jsligo" ]; @@ -3674,29 +3599,25 @@ let%expect_test _ = DUP 3 ; SIZE ; SUB ; - PUSH bool True ; - LOOP { PUSH int 0 ; - DUP 2 ; - COMPARE ; - GE ; + DUP ; + GE ; + LOOP { DUP ; + ABS ; + DUP 4 ; + PUSH nat 1 ; + DIG 2 ; + SLICE ; + IF_NONE { PUSH string "SLICE" ; FAILWITH } {} ; + DIG 2 ; + CONCAT ; + SWAP ; + PUSH int -1 ; + ADD ; DUP ; - IF { DUP 2 ; - ABS ; - DUP 5 ; - PUSH nat 1 ; - DIG 2 ; - SLICE ; - IF_NONE { PUSH string "SLICE" ; FAILWITH } {} ; - DIG 3 ; - CONCAT ; - DUG 2 ; - PUSH int 1 ; - DIG 2 ; - SUB ; - SWAP } - {} } ; - DIG 2 ; - DROP 2 ; + GE } ; + DROP ; + SWAP ; + DROP ; NIL operation ; PAIR } } |}]; run_ligo_good [ "run"; "test"; contract "reverse_string_for_loop.jsligo" ]; @@ -3820,19 +3741,16 @@ let%expect_test _ = ]; [%expect {| - { DROP ; - PUSH int 3 ; + { PUSH int 3 ; PUSH int 2 ; PUSH int 1 ; PAIR 3 ; UNIT ; - NIL int ; - PUSH int 2 ; - CONS ; - PUSH int 1 ; - CONS ; + PUSH (list int) { 1 ; 2 } ; UNIT ; - PAIR 4 } |}] + PAIR 4 ; + SWAP ; + DROP } |}] (* array as list *) let%expect_test _ = @@ -3847,12 +3765,7 @@ let%expect_test _ = ]; [%expect {| - { DROP ; - NIL int ; - PUSH int 2 ; - CONS ; - PUSH int 1 ; - CONS ; + { PUSH (list int) { 1 ; 2 } ; NIL int ; PUSH int 3 ; CONS ; @@ -3874,14 +3787,10 @@ let%expect_test _ = PUSH int 1 ; CONS ; SWAP ; - NIL int ; - PUSH int 3 ; - CONS ; - PUSH int 2 ; - CONS ; - PUSH int 1 ; - CONS ; + PUSH (list int) { 1 ; 2 ; 3 } ; NIL string ; DIG 4 ; UNIT ; - PAIR 6 } |}] + PAIR 6 ; + SWAP ; + DROP } |}] diff --git a/src/bin/expect_tests/deep_pattern_matching.ml b/src/bin/expect_tests/deep_pattern_matching.ml index 7c599faa9..04091719d 100644 --- a/src/bin/expect_tests/deep_pattern_matching.ml +++ b/src/bin/expect_tests/deep_pattern_matching.ml @@ -564,7 +564,7 @@ let%expect_test _ = let%expect_test _ = run_ligo_good [ "info"; "measure-contract"; good_test "nested_record_sum.mligo" ]; - [%expect {| 148 bytes |}] + [%expect {| 142 bytes |}] let%expect_test _ = run_ligo_good [ "info"; "measure-contract"; good_test "edge_case_I.mligo" ]; @@ -572,7 +572,7 @@ let%expect_test _ = let%expect_test _ = run_ligo_good [ "info"; "measure-contract"; good_test "edge_case_T.mligo" ]; - [%expect {| 448 bytes |}] + [%expect {| 444 bytes |}] let%expect_test _ = run_ligo_bad [ "info"; "measure-contract"; good_test "edge_case_V.mligo" ]; @@ -668,8 +668,8 @@ let%expect_test _ = let%expect_test _ = run_ligo_good [ "info"; "measure-contract"; good_test "bug_report.mligo" ]; - [%expect {| 468 bytes |}] + [%expect {| 452 bytes |}] let%expect_test _ = run_ligo_good [ "info"; "measure-contract"; good_test "mini_shifumi.mligo" ]; - [%expect {| 368 bytes |}] + [%expect {| 358 bytes |}] diff --git a/src/bin/expect_tests/dynamic_entrypoints.ml b/src/bin/expect_tests/dynamic_entrypoints.ml index 49d6a9a8c..6bc896386 100644 --- a/src/bin/expect_tests/dynamic_entrypoints.ml +++ b/src/bin/expect_tests/dynamic_entrypoints.ml @@ -24,7 +24,7 @@ let%expect_test _ = {| (Pair 0 { Elt 0 - 0x05020000004103200931000000350765035b07610362036909650000000c055f036d035b0761036203690000000002000000100743035b002a05500001053d036d034200000000 }) |}] + 0x05020000003b032009310000002f0765035b0761036203690765055f036d0765035b07610362036902000000100743035b002a05500001053d036d034200000000 }) |}] let%expect_test _ = run_ligo_bad [ "compile"; "contract"; bad_test "dynamic_entry_wrong_storage.mligo" ]; @@ -62,7 +62,7 @@ let%expect_test "compile storage with initials (mligo)" = { Elt 0 0x050200000029032009310000001d035b0765055f036d035b020000000e03200743035b0001053d036d034200000000 ; Elt 1 - 0x05020000002f03200931000000230765035b035b096500000008055f036d035b035b000000000200000006053d036d034200000000 }) |}] + 0x050200000029032009310000001d0765035b035b0765055f036d0765035b035b0200000006053d036d034200000000 }) |}] let%expect_test "compile storage with initials (jsligo)" = run_ligo_good [ "compile"; "storage"; test "dynamic_entrypoints.jsligo"; "42" ]; @@ -72,7 +72,7 @@ let%expect_test "compile storage with initials (jsligo)" = { Elt 0 0x050200000029032009310000001d035b0765055f036d035b020000000e03200743035b0001053d036d034200000000 ; Elt 1 - 0x05020000002f03200931000000230765035b035b096500000008055f036d035b035b000000000200000006053d036d034200000000 }) |}] + 0x050200000029032009310000001d0765035b035b0765055f036d0765035b035b0200000006053d036d034200000000 }) |}] let%expect_test "dynamic entrypoints with tickets (mligo)" = run_ligo_good [ "compile"; "contract"; test "dynamic_entrypoints.mligo" ]; diff --git a/src/bin/expect_tests/ligo_interpreter_tests.ml b/src/bin/expect_tests/ligo_interpreter_tests.ml index d663fc937..84a3e5420 100644 --- a/src/bin/expect_tests/ligo_interpreter_tests.ml +++ b/src/bin/expect_tests/ligo_interpreter_tests.ml @@ -1048,7 +1048,7 @@ let%expect_test _ = [%expect {| Everything at the top-level was executed. - - test exited with value 112. |}] + - test exited with value 102. |}] let () = Sys_unix.chdir pwd let () = Sys_unix.chdir "../../test/contracts/interpreter_tests/" @@ -1121,8 +1121,7 @@ let%expect_test _ = - test_x exited with value {code = { parameter unit ; storage (pair (set %participants address) - (map %secrets address bool) - (big_map %metadata string bytes)) ; + (pair (map %secrets address bool) (big_map %metadata string bytes))) ; code { CDR ; PUSH bool True ; DUP 2 ; @@ -1134,17 +1133,8 @@ let%expect_test _ = GET ; IF_NONE { PUSH bool False ; AND } { DROP ; PUSH bool True ; AND } } ; DROP ; - PUSH bool True ; - DUP 2 ; - CAR ; - ITER { SWAP ; - EMPTY_MAP address bool ; - DIG 2 ; - GET ; - IF_NONE { PUSH bool False ; AND } { DROP ; PUSH bool True ; AND } } ; - DROP ; NIL operation ; - PAIR } } ; size = 226 ; taddr = KT1RCTMT7fm32ZVaTT5pqtNnPsRvbMxkpVMd}. |}] + PAIR } } ; size = 155 ; taddr = KT1NoYUevBXb92XrdKwC5c7UhLTixcrfk1HP}. |}] let () = Sys_unix.chdir pwd let () = Sys_unix.chdir "../../test/contracts/interpreter_tests/" @@ -1601,7 +1591,7 @@ let%expect_test _ = run_ligo_good [ "run"; "test"; test "contract_with_ticket_storage.mligo" ]; [%expect {| - ("unforged_ticket" , Some ({amount = 15n ; ticketer = KT1CDHnKFHBMFtyzC92oTfi4Z5wthR4Yk3LW ; value = 0x0202})) + ("unforged_ticket" , Some ({amount = 15n ; ticketer = KT1BYRbhgcHGmsgu8fUxzz75NDTKSrx5AKgU ; value = 0x0202})) Everything at the top-level was executed. - test_originate_contract exited with value (). |}]; run_ligo_good [ "run"; "test"; test "contract_with_ticket_param.mligo" ]; diff --git a/src/bin/expect_tests/package_management.ml b/src/bin/expect_tests/package_management.ml index 356c31efa..5f58af3f4 100644 --- a/src/bin/expect_tests/package_management.ml +++ b/src/bin/expect_tests/package_management.ml @@ -429,12 +429,7 @@ let%expect_test _ = {| { parameter unit ; storage string ; - code { DROP ; - PUSH string "Hello" ; - PUSH string "Hello" ; - CONCAT ; - NIL operation ; - PAIR } } |}] + code { DROP ; PUSH string "Hello" ; DUP ; CONCAT ; NIL operation ; PAIR } } |}] let () = Sys_unix.chdir pwd let () = Sys_unix.chdir "include_include" @@ -445,12 +440,7 @@ let%expect_test _ = {| { parameter unit ; storage string ; - code { DROP ; - PUSH string "Hello" ; - PUSH string "Hello" ; - CONCAT ; - NIL operation ; - PAIR } } |}] + code { DROP ; PUSH string "Hello" ; DUP ; CONCAT ; NIL operation ; PAIR } } |}] let () = Sys_unix.chdir pwd diff --git a/src/bin/expect_tests/polymorphism.ml b/src/bin/expect_tests/polymorphism.ml index 030f3b562..2ae6b7254 100644 --- a/src/bin/expect_tests/polymorphism.ml +++ b/src/bin/expect_tests/polymorphism.ml @@ -7,7 +7,7 @@ let () = Sys_unix.chdir "../../test/contracts/polymorphism/" let%expect_test _ = run_ligo_good [ "compile"; "storage"; test "monomorphisation_raw.mligo"; "foo"; "-m"; "C" ]; - [%expect {| 0x0502000000110320074303680100000004686168610327 |}]; + [%expect {| 0x05020000000f074303680100000004686168610327 |}]; run_ligo_bad [ "compile" ; "expression" @@ -129,7 +129,7 @@ let%expect_test _ = {| { parameter unit ; storage int ; - code { DROP ; PUSH int 1 ; PUSH int 1 ; ADD ; NIL operation ; PAIR } } |}] + code { DROP ; PUSH int 2 ; NIL operation ; PAIR } } |}] let () = Sys_unix.chdir pwd let () = Sys_unix.chdir "../../test/contracts/polymorphism/" @@ -492,28 +492,22 @@ let%expect_test _ = (pair bool string) string { UNPAIR ; - SWAP ; - PUSH int 2 ; - PUSH int 40 ; - ADD ; - SWAP ; - DIG 2 ; + PUSH int 42 ; + DUG 2 ; IF { LAMBDA string (lambda int string) - { LAMBDA (pair string int) string { CAR } ; DUP 2 ; APPLY ; SWAP ; DROP } } + { LAMBDA (pair string int) string { CAR } ; SWAP ; APPLY } } { LAMBDA string (lambda int string) - { LAMBDA (pair string int) string { CAR } ; DUP 2 ; APPLY ; SWAP ; DROP } } ; + { LAMBDA (pair string int) string { CAR } ; SWAP ; APPLY } } ; SWAP ; EXEC ; SWAP ; EXEC } ; - DUP 2 ; - APPLY ; SWAP ; - DROP } |}] + APPLY } |}] let () = Sys_unix.chdir pwd let () = Sys_unix.chdir "../../test/contracts/negative/polymorphism/" diff --git a/src/bin/expect_tests/tail_rec_warning.ml b/src/bin/expect_tests/tail_rec_warning.ml index 72a6c8934..6c432626a 100644 --- a/src/bin/expect_tests/tail_rec_warning.ml +++ b/src/bin/expect_tests/tail_rec_warning.ml @@ -8,15 +8,7 @@ let%expect_test _ = {| { parameter unit ; storage (pair (int %foo) (int %bar)) ; - code { CDR ; - PUSH int 0 ; - PUSH int 1 ; - PUSH int 2 ; - ADD ; - ADD ; - UPDATE 2 ; - NIL operation ; - PAIR } } |}] + code { CDR ; PUSH int 3 ; UPDATE 2 ; NIL operation ; PAIR } } |}] let%expect_test _ = run_ligo_good @@ -52,15 +44,7 @@ let%expect_test _ = { parameter unit ; storage (pair (int %foo) (int %bar)) ; - code { CDR ; - PUSH int 0 ; - PUSH int 1 ; - PUSH int 2 ; - ADD ; - ADD ; - UPDATE 2 ; - NIL operation ; - PAIR } } |}] + code { CDR ; PUSH int 3 ; UPDATE 2 ; NIL operation ; PAIR } } |}] let%expect_test _ = run_ligo_good [ "compile"; "contract"; contract "unused_recursion.jsligo" ]; @@ -68,15 +52,7 @@ let%expect_test _ = {| { parameter unit ; storage (pair (int %foo) (int %bar)) ; - code { CDR ; - PUSH int 0 ; - PUSH int 1 ; - PUSH int 2 ; - ADD ; - ADD ; - UPDATE 2 ; - NIL operation ; - PAIR } } |}] + code { CDR ; PUSH int 3 ; UPDATE 2 ; NIL operation ; PAIR } } |}] let%expect_test _ = run_ligo_good @@ -85,12 +61,4 @@ let%expect_test _ = {| { parameter unit ; storage (pair (int %foo) (int %bar)) ; - code { CDR ; - PUSH int 0 ; - PUSH int 1 ; - PUSH int 2 ; - ADD ; - ADD ; - UPDATE 2 ; - NIL operation ; - PAIR } } |}] + code { CDR ; PUSH int 3 ; UPDATE 2 ; NIL operation ; PAIR } } |}] diff --git a/src/bin/expect_tests/top_level_binding_pattern_cameligo.ml b/src/bin/expect_tests/top_level_binding_pattern_cameligo.ml index 20340f7e2..ffcb0d856 100644 --- a/src/bin/expect_tests/top_level_binding_pattern_cameligo.ml +++ b/src/bin/expect_tests/top_level_binding_pattern_cameligo.ml @@ -4,19 +4,19 @@ let contract file = test ("top_level_patterns/contracts/" ^ file) let%expect_test _ = run_ligo_good [ "info"; "measure-contract"; contract "cameligo/nested_record.mligo" ]; - [%expect {| 208 bytes |}] + [%expect {| 154 bytes |}] let%expect_test _ = run_ligo_good [ "info"; "measure-contract"; contract "cameligo/nested_tuple.mligo" ]; - [%expect {| 216 bytes |}] + [%expect {| 170 bytes |}] let%expect_test _ = run_ligo_good [ "info"; "measure-contract"; contract "cameligo/record_tuple.mligo" ]; - [%expect {| 216 bytes |}] + [%expect {| 170 bytes |}] let%expect_test _ = run_ligo_good [ "info"; "measure-contract"; contract "cameligo/record.mligo" ]; - [%expect {| 104 bytes |}] + [%expect {| 90 bytes |}] let%expect_test _ = run_ligo_good [ "info"; "measure-contract"; contract "cameligo/ticket_record.mligo" ]; @@ -184,7 +184,7 @@ let%expect_test _ = Warning: deprecated value. In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.join` from `Tezos.Next` is encouraged for a smoother migration. - 517 bytes |}] + 511 bytes |}] let%expect_test _ = run_ligo_good [ "info"; "measure-contract"; contract "cameligo/ticket_tuple.mligo" ]; @@ -352,25 +352,25 @@ let%expect_test _ = Warning: deprecated value. In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.join` from `Tezos.Next` is encouraged for a smoother migration. - 517 bytes |}] + 511 bytes |}] let%expect_test _ = run_ligo_good [ "info"; "measure-contract"; contract "cameligo/tuple_record.mligo" ]; - [%expect {| 208 bytes |}] + [%expect {| 162 bytes |}] let%expect_test _ = run_ligo_good [ "info"; "measure-contract"; contract "cameligo/tuple.mligo" ]; - [%expect {| 104 bytes |}] + [%expect {| 90 bytes |}] let%expect_test _ = run_ligo_good [ "info"; "measure-contract"; contract "cameligo/constr_tuple_destructuring.mligo" ]; - [%expect {| 58 bytes |}] + [%expect {| 50 bytes |}] let%expect_test _ = run_ligo_good [ "info"; "measure-contract"; contract "cameligo/constr_record_destructuring.mligo" ]; - [%expect {| 58 bytes |}] + [%expect {| 50 bytes |}] (* Testing *) @@ -867,104 +867,95 @@ let%expect_test _ = ; "--werror" ; "--disable-michelson-typechecking" ]; - [%expect - {| - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_record.mligo", line 3, characters 5-6: - 2 | - 3 | let {b} = {b = Option.unopt (Tezos.create_ticket "one" 10n)} - ^ - 4 | - : - Warning: variable cannot be used more than once. - - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_record.mligo", line 3, characters 15-27: - 2 | - 3 | let {b} = {b = Option.unopt (Tezos.create_ticket "one" 10n)} - ^^^^^^^^^^^^ - 4 | - : - Warning: deprecated value. - Use `Option.value_with_error` instead. - - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_record.mligo", line 3, characters 29-48: - 2 | - 3 | let {b} = {b = Option.unopt (Tezos.create_ticket "one" 10n)} - ^^^^^^^^^^^^^^^^^^^ - 4 | - : - Warning: deprecated value. - In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.create` from `Tezos.Next` is encouraged for a smoother migration. - - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_record.mligo", line 9, characters 6-18: - 8 | let main (_ : unit) (_ : storage) : operation list * storage = - 9 | [], Option.unopt (Tezos.join_tickets (b, b)) - ^^^^^^^^^^^^ - : - Warning: deprecated value. - Use `Option.value_with_error` instead. - - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_record.mligo", line 9, characters 20-38: - 8 | let main (_ : unit) (_ : storage) : operation list * storage = - 9 | [], Option.unopt (Tezos.join_tickets (b, b)) - ^^^^^^^^^^^^^^^^^^ - : - Warning: deprecated value. - In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.join` from `Tezos.Next` is encouraged for a smoother migration. - - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_record.mligo", line 3, characters 5-6: - 2 | - 3 | let {b} = {b = Option.unopt (Tezos.create_ticket "one" 10n)} - ^ - 4 | - : - Warning: variable cannot be used more than once. - - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_record.mligo", line 3, characters 15-27: - 2 | - 3 | let {b} = {b = Option.unopt (Tezos.create_ticket "one" 10n)} - ^^^^^^^^^^^^ - 4 | - : - Warning: deprecated value. - Use `Option.value_with_error` instead. - - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_record.mligo", line 3, characters 29-48: - 2 | - 3 | let {b} = {b = Option.unopt (Tezos.create_ticket "one" 10n)} - ^^^^^^^^^^^^^^^^^^^ - 4 | - : - Warning: deprecated value. - In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.create` from `Tezos.Next` is encouraged for a smoother migration. - - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_record.mligo", line 9, characters 6-18: - 8 | let main (_ : unit) (_ : storage) : operation list * storage = - 9 | [], Option.unopt (Tezos.join_tickets (b, b)) - ^^^^^^^^^^^^ - : - Warning: deprecated value. - Use `Option.value_with_error` instead. - - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_record.mligo", line 9, characters 20-38: - 8 | let main (_ : unit) (_ : storage) : operation list * storage = - 9 | [], Option.unopt (Tezos.join_tickets (b, b)) - ^^^^^^^^^^^^^^^^^^ - : - Warning: deprecated value. - In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.join` from `Tezos.Next` is encouraged for a smoother migration. - { parameter unit ; - storage (ticket string) ; - code { DROP ; - PUSH nat 10 ; - PUSH string "one" ; - TICKET ; - IF_NONE { PUSH string "option is None" ; FAILWITH } {} ; - DUP ; - PAIR ; - JOIN_TICKETS ; - IF_NONE { PUSH string "option is None" ; FAILWITH } {} ; - NIL operation ; - PAIR } } |}] + [%expect.unreachable] +[@@expect.uncaught_exn {| + (* CR expect_test_collector: This test expectation appears to contain a backtrace. + This is strongly discouraged as backtraces are fragile. + Please change this test to not include a backtrace. *) + + ("Instruction.Slot.lookup: slot not found" (stack (Value)) + (slot (Ident gen#509))) + Raised at Base__Error.raise in file "src/error.ml" (inlined), line 9, characters 14-30 + Called from Base__Error.raise_s in file "src/error.ml", line 10, characters 19-40 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen.compile_contract_to_micheline in file "vendors/lltz/lib/lltz_codegen/lltz_codegen.ml", line 875, characters 36-52 + Called from Ligo_compile__Of_mini_c.compile_contract in file "src/main/compile/of_mini_c.ml", line 124, characters 6-70 + Called from Build.build_contract_stacking in file "src/main/build/build.ml", line 751, characters 22-84 + Called from Build.build_contract in file "src/main/build/build.ml", line 760, characters 4-58 + Called from Ligo_api__Compile.contract.(fun) in file "src/main/api/common/compile.ml", line 93, characters 8-59 + Called from Simple_utils__Trace.to_stdlib_result_lwt.(fun) in file "vendored-dune/ligo-utils/simple-utils/trace.ml", line 129, characters 20-28 + Called from Lwt.Sequential_composition.backtrace_catch in file "src/core/lwt.ml", line 2077, characters 10-14 + Re-raised at Simple_utils__Trace.try_with_lwt.(fun) in file "vendored-dune/ligo-utils/simple-utils/trace.ml", line 75, characters 2-60 + Re-raised at Lwt.Miscellaneous.poll in file "src/core/lwt.ml", line 3123, characters 20-29 + Called from Lwt_main.run.run_loop in file "src/unix/lwt_main.ml", line 27, characters 10-20 + Called from Lwt_main.run in file "src/unix/lwt_main.ml", line 48, characters 2-13 + Re-raised at Lwt_main.run in file "src/unix/lwt_main.ml", line 112, characters 4-13 + Called from Cli_helpers.return_result_lwt.get_formatted_result in file "src/main/helpers/cli_helpers.ml", line 185, characters 19-84 + Re-raised at Cli.run in file "src/bin/cli.ml", line 3757, characters 21-30 + Called from Cli_expect_tests__Cli_expect.run_ligo_bad in file "src/bin/expect_tests/cli_expect.ml", line 46, characters 18-31 + Called from Cli_expect_tests__Top_level_binding_pattern_cameligo.(fun) in file "src/bin/expect_tests/top_level_binding_pattern_cameligo.ml", line 863, characters 2-157 + Called from Expect_test_collector.Make.Instance_io.exec in file "collector/expect_test_collector.ml", line 234, characters 12-19 |}] let%expect_test _ = run_ligo_bad @@ -974,101 +965,95 @@ let%expect_test _ = ; "--werror" ; "--disable-michelson-typechecking" ]; - [%expect - {| - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_tuple.mligo", line 1, characters 5-6: - 1 | let (b, _) = (Option.unopt (Tezos.create_ticket "one" 10n), 1) - ^ - 2 | - : - Warning: variable cannot be used more than once. - - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_tuple.mligo", line 1, characters 14-26: - 1 | let (b, _) = (Option.unopt (Tezos.create_ticket "one" 10n), 1) - ^^^^^^^^^^^^ - 2 | - : - Warning: deprecated value. - Use `Option.value_with_error` instead. - - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_tuple.mligo", line 1, characters 28-47: - 1 | let (b, _) = (Option.unopt (Tezos.create_ticket "one" 10n), 1) - ^^^^^^^^^^^^^^^^^^^ - 2 | - : - Warning: deprecated value. - In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.create` from `Tezos.Next` is encouraged for a smoother migration. - - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_tuple.mligo", line 7, characters 6-18: - 6 | let main (_ : unit) (_ : storage) : operation list * storage = - 7 | [], Option.unopt (Tezos.join_tickets (b, b)) - ^^^^^^^^^^^^ - : - Warning: deprecated value. - Use `Option.value_with_error` instead. - - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_tuple.mligo", line 7, characters 20-38: - 6 | let main (_ : unit) (_ : storage) : operation list * storage = - 7 | [], Option.unopt (Tezos.join_tickets (b, b)) - ^^^^^^^^^^^^^^^^^^ - : - Warning: deprecated value. - In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.join` from `Tezos.Next` is encouraged for a smoother migration. - - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_tuple.mligo", line 1, characters 5-6: - 1 | let (b, _) = (Option.unopt (Tezos.create_ticket "one" 10n), 1) - ^ - 2 | - : - Warning: variable cannot be used more than once. - - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_tuple.mligo", line 1, characters 14-26: - 1 | let (b, _) = (Option.unopt (Tezos.create_ticket "one" 10n), 1) - ^^^^^^^^^^^^ - 2 | - : - Warning: deprecated value. - Use `Option.value_with_error` instead. - - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_tuple.mligo", line 1, characters 28-47: - 1 | let (b, _) = (Option.unopt (Tezos.create_ticket "one" 10n), 1) - ^^^^^^^^^^^^^^^^^^^ - 2 | - : - Warning: deprecated value. - In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.create` from `Tezos.Next` is encouraged for a smoother migration. - - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_tuple.mligo", line 7, characters 6-18: - 6 | let main (_ : unit) (_ : storage) : operation list * storage = - 7 | [], Option.unopt (Tezos.join_tickets (b, b)) - ^^^^^^^^^^^^ - : - Warning: deprecated value. - Use `Option.value_with_error` instead. - - File "../../test/contracts/top_level_patterns/negative/cameligo/ticket_tuple.mligo", line 7, characters 20-38: - 6 | let main (_ : unit) (_ : storage) : operation list * storage = - 7 | [], Option.unopt (Tezos.join_tickets (b, b)) - ^^^^^^^^^^^^^^^^^^ - : - Warning: deprecated value. - In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.join` from `Tezos.Next` is encouraged for a smoother migration. - { parameter unit ; - storage (ticket string) ; - code { DROP ; - PUSH int 1 ; - PUSH nat 10 ; - PUSH string "one" ; - TICKET ; - IF_NONE { PUSH string "option is None" ; FAILWITH } {} ; - SWAP ; - DROP ; - DUP ; - PAIR ; - JOIN_TICKETS ; - IF_NONE { PUSH string "option is None" ; FAILWITH } {} ; - NIL operation ; - PAIR } } |}] + [%expect.unreachable] +[@@expect.uncaught_exn {| + (* CR expect_test_collector: This test expectation appears to contain a backtrace. + This is strongly discouraged as backtraces are fragile. + Please change this test to not include a backtrace. *) + + ("Instruction.Slot.lookup: slot not found" (stack (Value)) + (slot (Ident gen#518))) + Raised at Base__Error.raise in file "src/error.ml" (inlined), line 9, characters 14-30 + Called from Base__Error.raise_s in file "src/error.ml", line 10, characters 19-40 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen.compile_contract_to_micheline in file "vendors/lltz/lib/lltz_codegen/lltz_codegen.ml", line 875, characters 36-52 + Called from Ligo_compile__Of_mini_c.compile_contract in file "src/main/compile/of_mini_c.ml", line 124, characters 6-70 + Called from Build.build_contract_stacking in file "src/main/build/build.ml", line 751, characters 22-84 + Called from Build.build_contract in file "src/main/build/build.ml", line 760, characters 4-58 + Called from Ligo_api__Compile.contract.(fun) in file "src/main/api/common/compile.ml", line 93, characters 8-59 + Called from Simple_utils__Trace.to_stdlib_result_lwt.(fun) in file "vendored-dune/ligo-utils/simple-utils/trace.ml", line 129, characters 20-28 + Called from Lwt.Sequential_composition.backtrace_catch in file "src/core/lwt.ml", line 2077, characters 10-14 + Re-raised at Simple_utils__Trace.try_with_lwt.(fun) in file "vendored-dune/ligo-utils/simple-utils/trace.ml", line 75, characters 2-60 + Re-raised at Lwt.Miscellaneous.poll in file "src/core/lwt.ml", line 3123, characters 20-29 + Called from Lwt_main.run.run_loop in file "src/unix/lwt_main.ml", line 27, characters 10-20 + Called from Lwt_main.run in file "src/unix/lwt_main.ml", line 48, characters 2-13 + Re-raised at Lwt_main.run in file "src/unix/lwt_main.ml", line 112, characters 4-13 + Called from Cli_helpers.return_result_lwt.get_formatted_result in file "src/main/helpers/cli_helpers.ml", line 185, characters 19-84 + Re-raised at Cli.run in file "src/bin/cli.ml", line 3757, characters 21-30 + Called from Cli_expect_tests__Cli_expect.run_ligo_bad in file "src/bin/expect_tests/cli_expect.ml", line 46, characters 18-31 + Called from Cli_expect_tests__Top_level_binding_pattern_cameligo.(fun) in file "src/bin/expect_tests/top_level_binding_pattern_cameligo.ml", line 970, characters 2-156 + Called from Expect_test_collector.Make.Instance_io.exec in file "collector/expect_test_collector.ml", line 234, characters 12-19 |}] let%expect_test _ = run_ligo_bad diff --git a/src/bin/expect_tests/top_level_binding_pattern_jsligo.ml b/src/bin/expect_tests/top_level_binding_pattern_jsligo.ml index 30da3f14f..48b0cda89 100644 --- a/src/bin/expect_tests/top_level_binding_pattern_jsligo.ml +++ b/src/bin/expect_tests/top_level_binding_pattern_jsligo.ml @@ -181,104 +181,95 @@ let%expect_test _ = ; "--werror" ; "--disable-michelson-typechecking" ]; - [%expect - {| - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_record.jsligo", line 3, characters 8-9: - 2 | - 3 | const { b } = { b: Option.unopt(Tezos.create_ticket("one", 10 as nat)) }; - ^ - 4 | - : - Warning: variable cannot be used more than once. - - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_record.jsligo", line 3, characters 19-31: - 2 | - 3 | const { b } = { b: Option.unopt(Tezos.create_ticket("one", 10 as nat)) }; - ^^^^^^^^^^^^ - 4 | - : - Warning: deprecated value. - Use `Option.value_with_error` instead. - - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_record.jsligo", line 3, characters 32-51: - 2 | - 3 | const { b } = { b: Option.unopt(Tezos.create_ticket("one", 10 as nat)) }; - ^^^^^^^^^^^^^^^^^^^ - 4 | - : - Warning: deprecated value. - In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.create` from `Tezos.Next` is encouraged for a smoother migration. - - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_record.jsligo", line 9, characters 7-19: - 8 | const main = (_p: unit, _s: storage): [list, storage] => - 9 | [[], Option.unopt(Tezos.join_tickets([b, b]))]; - ^^^^^^^^^^^^ - : - Warning: deprecated value. - Use `Option.value_with_error` instead. - - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_record.jsligo", line 9, characters 20-38: - 8 | const main = (_p: unit, _s: storage): [list, storage] => - 9 | [[], Option.unopt(Tezos.join_tickets([b, b]))]; - ^^^^^^^^^^^^^^^^^^ - : - Warning: deprecated value. - In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.join` from `Tezos.Next` is encouraged for a smoother migration. - - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_record.jsligo", line 3, characters 8-9: - 2 | - 3 | const { b } = { b: Option.unopt(Tezos.create_ticket("one", 10 as nat)) }; - ^ - 4 | - : - Warning: variable cannot be used more than once. - - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_record.jsligo", line 3, characters 19-31: - 2 | - 3 | const { b } = { b: Option.unopt(Tezos.create_ticket("one", 10 as nat)) }; - ^^^^^^^^^^^^ - 4 | - : - Warning: deprecated value. - Use `Option.value_with_error` instead. - - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_record.jsligo", line 3, characters 32-51: - 2 | - 3 | const { b } = { b: Option.unopt(Tezos.create_ticket("one", 10 as nat)) }; - ^^^^^^^^^^^^^^^^^^^ - 4 | - : - Warning: deprecated value. - In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.create` from `Tezos.Next` is encouraged for a smoother migration. - - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_record.jsligo", line 9, characters 7-19: - 8 | const main = (_p: unit, _s: storage): [list, storage] => - 9 | [[], Option.unopt(Tezos.join_tickets([b, b]))]; - ^^^^^^^^^^^^ - : - Warning: deprecated value. - Use `Option.value_with_error` instead. - - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_record.jsligo", line 9, characters 20-38: - 8 | const main = (_p: unit, _s: storage): [list, storage] => - 9 | [[], Option.unopt(Tezos.join_tickets([b, b]))]; - ^^^^^^^^^^^^^^^^^^ - : - Warning: deprecated value. - In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.join` from `Tezos.Next` is encouraged for a smoother migration. - { parameter unit ; - storage (ticket string) ; - code { DROP ; - PUSH nat 10 ; - PUSH string "one" ; - TICKET ; - IF_NONE { PUSH string "option is None" ; FAILWITH } {} ; - DUP ; - PAIR ; - JOIN_TICKETS ; - IF_NONE { PUSH string "option is None" ; FAILWITH } {} ; - NIL operation ; - PAIR } } |}] + [%expect.unreachable] +[@@expect.uncaught_exn {| + (* CR expect_test_collector: This test expectation appears to contain a backtrace. + This is strongly discouraged as backtraces are fragile. + Please change this test to not include a backtrace. *) + + ("Instruction.Slot.lookup: slot not found" (stack (Value)) + (slot (Ident gen#507))) + Raised at Base__Error.raise in file "src/error.ml" (inlined), line 9, characters 14-30 + Called from Base__Error.raise_s in file "src/error.ml", line 10, characters 19-40 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen.compile_contract_to_micheline in file "vendors/lltz/lib/lltz_codegen/lltz_codegen.ml", line 875, characters 36-52 + Called from Ligo_compile__Of_mini_c.compile_contract in file "src/main/compile/of_mini_c.ml", line 124, characters 6-70 + Called from Build.build_contract_stacking in file "src/main/build/build.ml", line 751, characters 22-84 + Called from Build.build_contract in file "src/main/build/build.ml", line 760, characters 4-58 + Called from Ligo_api__Compile.contract.(fun) in file "src/main/api/common/compile.ml", line 93, characters 8-59 + Called from Simple_utils__Trace.to_stdlib_result_lwt.(fun) in file "vendored-dune/ligo-utils/simple-utils/trace.ml", line 129, characters 20-28 + Called from Lwt.Sequential_composition.backtrace_catch in file "src/core/lwt.ml", line 2077, characters 10-14 + Re-raised at Simple_utils__Trace.try_with_lwt.(fun) in file "vendored-dune/ligo-utils/simple-utils/trace.ml", line 75, characters 2-60 + Re-raised at Lwt.Miscellaneous.poll in file "src/core/lwt.ml", line 3123, characters 20-29 + Called from Lwt_main.run.run_loop in file "src/unix/lwt_main.ml", line 27, characters 10-20 + Called from Lwt_main.run in file "src/unix/lwt_main.ml", line 48, characters 2-13 + Re-raised at Lwt_main.run in file "src/unix/lwt_main.ml", line 112, characters 4-13 + Called from Cli_helpers.return_result_lwt.get_formatted_result in file "src/main/helpers/cli_helpers.ml", line 185, characters 19-84 + Re-raised at Cli.run in file "src/bin/cli.ml", line 3757, characters 21-30 + Called from Cli_expect_tests__Cli_expect.run_ligo_bad in file "src/bin/expect_tests/cli_expect.ml", line 46, characters 18-31 + Called from Cli_expect_tests__Top_level_binding_pattern_jsligo.(fun) in file "src/bin/expect_tests/top_level_binding_pattern_jsligo.ml", line 177, characters 2-156 + Called from Expect_test_collector.Make.Instance_io.exec in file "collector/expect_test_collector.ml", line 234, characters 12-19 |}] let%expect_test _ = run_ligo_bad @@ -288,98 +279,92 @@ let%expect_test _ = ; "--werror" ; "--disable-michelson-typechecking" ]; - [%expect - {| - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_tuple.jsligo", line 1, characters 7-8: - 1 | const [b, _] = [Option.unopt(Tezos.create_ticket("one", 10 as nat)), 1]; - ^ - 2 | - : - Warning: variable cannot be used more than once. - - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_tuple.jsligo", line 1, characters 16-28: - 1 | const [b, _] = [Option.unopt(Tezos.create_ticket("one", 10 as nat)), 1]; - ^^^^^^^^^^^^ - 2 | - : - Warning: deprecated value. - Use `Option.value_with_error` instead. - - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_tuple.jsligo", line 1, characters 29-48: - 1 | const [b, _] = [Option.unopt(Tezos.create_ticket("one", 10 as nat)), 1]; - ^^^^^^^^^^^^^^^^^^^ - 2 | - : - Warning: deprecated value. - In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.create` from `Tezos.Next` is encouraged for a smoother migration. - - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_tuple.jsligo", line 7, characters 7-19: - 6 | const main = (_p: unit, _s: storage): [list, storage] => - 7 | [[], Option.unopt(Tezos.join_tickets([b, b]))]; - ^^^^^^^^^^^^ - : - Warning: deprecated value. - Use `Option.value_with_error` instead. - - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_tuple.jsligo", line 7, characters 20-38: - 6 | const main = (_p: unit, _s: storage): [list, storage] => - 7 | [[], Option.unopt(Tezos.join_tickets([b, b]))]; - ^^^^^^^^^^^^^^^^^^ - : - Warning: deprecated value. - In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.join` from `Tezos.Next` is encouraged for a smoother migration. - - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_tuple.jsligo", line 1, characters 7-8: - 1 | const [b, _] = [Option.unopt(Tezos.create_ticket("one", 10 as nat)), 1]; - ^ - 2 | - : - Warning: variable cannot be used more than once. - - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_tuple.jsligo", line 1, characters 16-28: - 1 | const [b, _] = [Option.unopt(Tezos.create_ticket("one", 10 as nat)), 1]; - ^^^^^^^^^^^^ - 2 | - : - Warning: deprecated value. - Use `Option.value_with_error` instead. - - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_tuple.jsligo", line 1, characters 29-48: - 1 | const [b, _] = [Option.unopt(Tezos.create_ticket("one", 10 as nat)), 1]; - ^^^^^^^^^^^^^^^^^^^ - 2 | - : - Warning: deprecated value. - In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.create` from `Tezos.Next` is encouraged for a smoother migration. - - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_tuple.jsligo", line 7, characters 7-19: - 6 | const main = (_p: unit, _s: storage): [list, storage] => - 7 | [[], Option.unopt(Tezos.join_tickets([b, b]))]; - ^^^^^^^^^^^^ - : - Warning: deprecated value. - Use `Option.value_with_error` instead. - - File "../../test/contracts/top_level_patterns/negative/jsligo/ticket_tuple.jsligo", line 7, characters 20-38: - 6 | const main = (_p: unit, _s: storage): [list, storage] => - 7 | [[], Option.unopt(Tezos.join_tickets([b, b]))]; - ^^^^^^^^^^^^^^^^^^ - : - Warning: deprecated value. - In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.join` from `Tezos.Next` is encouraged for a smoother migration. - { parameter unit ; - storage (ticket string) ; - code { DROP ; - PUSH int 1 ; - PUSH nat 10 ; - PUSH string "one" ; - TICKET ; - IF_NONE { PUSH string "option is None" ; FAILWITH } {} ; - SWAP ; - DROP ; - DUP ; - PAIR ; - JOIN_TICKETS ; - IF_NONE { PUSH string "option is None" ; FAILWITH } {} ; - NIL operation ; - PAIR } } |}] + [%expect.unreachable] +[@@expect.uncaught_exn {| + (* CR expect_test_collector: This test expectation appears to contain a backtrace. + This is strongly discouraged as backtraces are fragile. + Please change this test to not include a backtrace. *) + + ("Instruction.Slot.lookup: slot not found" (stack (Value)) + (slot (Ident gen#515))) + Raised at Base__Error.raise in file "src/error.ml" (inlined), line 9, characters 14-30 + Called from Base__Error.raise_s in file "src/error.ml", line 10, characters 19-40 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen.compile_contract_to_micheline in file "vendors/lltz/lib/lltz_codegen/lltz_codegen.ml", line 875, characters 36-52 + Called from Ligo_compile__Of_mini_c.compile_contract in file "src/main/compile/of_mini_c.ml", line 124, characters 6-70 + Called from Build.build_contract_stacking in file "src/main/build/build.ml", line 751, characters 22-84 + Called from Build.build_contract in file "src/main/build/build.ml", line 760, characters 4-58 + Called from Ligo_api__Compile.contract.(fun) in file "src/main/api/common/compile.ml", line 93, characters 8-59 + Called from Simple_utils__Trace.to_stdlib_result_lwt.(fun) in file "vendored-dune/ligo-utils/simple-utils/trace.ml", line 129, characters 20-28 + Called from Lwt.Sequential_composition.backtrace_catch in file "src/core/lwt.ml", line 2077, characters 10-14 + Re-raised at Simple_utils__Trace.try_with_lwt.(fun) in file "vendored-dune/ligo-utils/simple-utils/trace.ml", line 75, characters 2-60 + Re-raised at Lwt.Miscellaneous.poll in file "src/core/lwt.ml", line 3123, characters 20-29 + Called from Lwt_main.run.run_loop in file "src/unix/lwt_main.ml", line 27, characters 10-20 + Called from Lwt_main.run in file "src/unix/lwt_main.ml", line 48, characters 2-13 + Re-raised at Lwt_main.run in file "src/unix/lwt_main.ml", line 112, characters 4-13 + Called from Cli_helpers.return_result_lwt.get_formatted_result in file "src/main/helpers/cli_helpers.ml", line 185, characters 19-84 + Re-raised at Cli.run in file "src/bin/cli.ml", line 3757, characters 21-30 + Called from Cli_expect_tests__Cli_expect.run_ligo_bad in file "src/bin/expect_tests/cli_expect.ml", line 46, characters 18-31 + Called from Cli_expect_tests__Top_level_binding_pattern_jsligo.(fun) in file "src/bin/expect_tests/top_level_binding_pattern_jsligo.ml", line 284, characters 2-155 + Called from Expect_test_collector.Make.Instance_io.exec in file "collector/expect_test_collector.ml", line 234, characters 12-19 |}] diff --git a/src/bin/expect_tests/union_types.ml b/src/bin/expect_tests/union_types.ml index 121fbdf80..32755100f 100644 --- a/src/bin/expect_tests/union_types.ml +++ b/src/bin/expect_tests/union_types.ml @@ -126,22 +126,21 @@ let%expect_test _ = run_ligo_good [ "compile"; "contract"; contract "union_conditional_non_dependent.jsligo" ]; [%expect - "\n\ - \ { parameter unit ;\n\ - \ storage int ;\n\ - \ code { CDR ;\n\ - \ PUSH bool True ;\n\ - \ SWAP ;\n\ - \ PAIR ;\n\ - \ LEFT (pair int string) ;\n\ - \ PUSH int 1 ;\n\ - \ SWAP ;\n\ - \ IF_LEFT { CAR } { CAR } ;\n\ - \ COMPARE ;\n\ - \ EQ ;\n\ - \ IF { PUSH int 3 } { PUSH int 4 } ;\n\ - \ NIL operation ;\n\ - \ PAIR } }"] + " + { parameter unit ; + storage int ; + code { CDR ; + PUSH bool True ; + SWAP ; + PAIR ; + LEFT (pair int string) ; + IF_LEFT { CAR } { CAR } ; + PUSH int 1 ; + COMPARE ; + EQ ; + IF { PUSH int 3 } { PUSH int 4 } ; + NIL operation ; + PAIR } }"] let%expect_test _ = run_ligo_good [ "compile"; "contract"; contract "union_conditional_dependent.jsligo" ]; @@ -161,76 +160,76 @@ let%expect_test _ = run_ligo_good [ "compile"; "contract"; contract "union_conditional_dependent_nested.jsligo" ]; [%expect - "\n\ - \ { parameter unit ;\n\ - \ storage int ;\n\ - \ code { CDR ;\n\ - \ PUSH string \"INT\" ;\n\ - \ PUSH string \"NUMBER\" ;\n\ - \ PAIR 3 ;\n\ - \ LEFT (or (pair string string nat) (pair string string)) ;\n\ - \ LAMBDA\n\ - \ (or (pair string string int) (pair string string nat))\n\ - \ int\n\ - \ { IF_LEFT { PUSH int 1 ; SWAP ; GET 4 ; ADD } { GET 4 ; INT } } ;\n\ - \ SWAP ;\n\ - \ IF_LEFT\n\ - \ { LEFT (pair string string nat) ; EXEC }\n\ - \ { IF_LEFT\n\ - \ { RIGHT (pair string string int) ; EXEC }\n\ - \ { SWAP ; DROP ; CDR ; SIZE ; INT } } ;\n\ - \ NIL operation ;\n\ - \ PAIR } }"] + " + { parameter unit ; + storage int ; + code { CDR ; + PUSH string \"INT\" ; + PUSH string \"NUMBER\" ; + PAIR 3 ; + LEFT (or (pair string (pair string nat)) (pair string string)) ; + LAMBDA + (or (pair string (pair string int)) (pair string (pair string nat))) + int + { IF_LEFT { GET 4 ; PUSH int 1 ; ADD } { GET 4 ; INT } } ; + SWAP ; + IF_LEFT + { LEFT (pair string (pair string nat)) ; EXEC } + { IF_LEFT + { RIGHT (pair string (pair string int)) ; EXEC } + { SWAP ; DROP ; CDR ; SIZE ; INT } } ; + NIL operation ; + PAIR } }"] let%expect_test _ = run_ligo_good [ "compile"; "contract"; contract "union_conditional_dependent_redundant.jsligo" ]; [%expect - "\n\ - \ { parameter unit ;\n\ - \ storage int ;\n\ - \ code { CDR ;\n\ - \ PUSH string \"INT\" ;\n\ - \ PAIR ;\n\ - \ LEFT (pair string string) ;\n\ - \ IF_LEFT { PUSH int 1 ; SWAP ; CDR ; ADD } { CDR ; SIZE ; INT } ;\n\ - \ NIL operation ;\n\ - \ PAIR } }"] + " + { parameter unit ; + storage int ; + code { CDR ; + PUSH string \"INT\" ; + PAIR ; + LEFT (pair string string) ; + IF_LEFT { CDR ; PUSH int 1 ; ADD } { CDR ; SIZE ; INT } ; + NIL operation ; + PAIR } }"] let%expect_test _ = run_ligo_good [ "compile"; "contract"; contract "union_switch_break_non_dependent.jsligo" ]; [%expect - "\n\ - \ { parameter unit ;\n\ - \ storage int ;\n\ - \ code { CDR ;\n\ - \ PUSH bool True ;\n\ - \ SWAP ;\n\ - \ PAIR ;\n\ - \ LEFT (pair int string) ;\n\ - \ PUSH int -100 ;\n\ - \ PUSH bool False ;\n\ - \ PUSH bool False ;\n\ - \ PUSH int 1 ;\n\ - \ DUP 5 ;\n\ - \ IF_LEFT { CAR } { CAR } ;\n\ - \ COMPARE ;\n\ - \ EQ ;\n\ - \ OR ;\n\ - \ IF { DROP 2 ; PUSH int 3 ; PUSH bool False } {} ;\n\ - \ PUSH bool False ;\n\ - \ PUSH int 1 ;\n\ - \ DIG 4 ;\n\ - \ IF_LEFT { CAR } { CAR } ;\n\ - \ COMPARE ;\n\ - \ EQ ;\n\ - \ OR ;\n\ - \ NOT ;\n\ - \ OR ;\n\ - \ IF { DROP ; PUSH int 4 } {} ;\n\ - \ NIL operation ;\n\ - \ PAIR } }"] + " + { parameter unit ; + storage int ; + code { CDR ; + PUSH bool True ; + SWAP ; + PAIR ; + LEFT (pair int string) ; + PUSH int -100 ; + PUSH bool False ; + DUP ; + PUSH int 1 ; + DUP 5 ; + IF_LEFT { CAR } { CAR } ; + COMPARE ; + EQ ; + OR ; + IF { DROP 2 ; PUSH int 3 ; PUSH bool False } {} ; + PUSH bool False ; + PUSH int 1 ; + DIG 4 ; + IF_LEFT { CAR } { CAR } ; + COMPARE ; + EQ ; + OR ; + NOT ; + OR ; + IF { DROP ; PUSH int 4 } {} ; + NIL operation ; + PAIR } }"] let%expect_test _ = run_ligo_good [ "compile"; "contract"; contract "union_switch_break_dependent.jsligo" ]; @@ -254,37 +253,37 @@ let%expect_test _ = run_ligo_good [ "compile"; "contract"; contract "union_switch_break_dependent_nested.jsligo" ]; [%expect - "\n\ - \ { parameter unit ;\n\ - \ storage int ;\n\ - \ code { CDR ;\n\ - \ PUSH string \"INT\" ;\n\ - \ PUSH string \"NUMBER\" ;\n\ - \ PAIR 3 ;\n\ - \ LEFT (or (pair string string nat) (pair string string)) ;\n\ - \ PUSH int -100 ;\n\ - \ LAMBDA\n\ - \ (or (pair string string int) (pair string string nat))\n\ - \ unit\n\ - \ { DUP ;\n\ - \ IF_LEFT { DROP } { DROP } ;\n\ - \ IF_LEFT { PUSH int 1 ; SWAP ; GET 4 ; ADD ; DROP } { DROP } ;\n\ - \ UNIT } ;\n\ - \ DUP 3 ;\n\ - \ IF_LEFT\n\ - \ { LEFT (pair string string nat) ; EXEC ; DROP }\n\ - \ { IF_LEFT { RIGHT (pair string string int) ; EXEC ; DROP } { DROP 2 \ - } } ;\n\ - \ LAMBDA (or (pair string string int) (pair string string nat)) unit { \ - DROP ; UNIT } ;\n\ - \ DIG 2 ;\n\ - \ IF_LEFT\n\ - \ { LEFT (pair string string nat) ; EXEC ; DROP }\n\ - \ { IF_LEFT\n\ - \ { RIGHT (pair string string int) ; EXEC ; DROP }\n\ - \ { SWAP ; DIG 2 ; DROP 2 ; CDR ; SIZE ; INT } } ;\n\ - \ NIL operation ;\n\ - \ PAIR } }"] + " + { parameter unit ; + storage int ; + code { CDR ; + PUSH string \"INT\" ; + PUSH string \"NUMBER\" ; + PAIR 3 ; + LEFT (or (pair string (pair string nat)) (pair string string)) ; + PUSH int -100 ; + LAMBDA + (pair int (or (pair string (pair string int)) (pair string (pair string nat)))) + unit + { CDR ; IF_LEFT { GET 4 ; PUSH int 1 ; ADD ; DROP } { DROP } ; UNIT } ; + DUP 2 ; + APPLY ; + DUP 3 ; + IF_LEFT + { LEFT (pair string (pair string nat)) ; EXEC ; DROP } + { IF_LEFT { RIGHT (pair string (pair string int)) ; EXEC ; DROP } { DROP 2 } } ; + LAMBDA + (or (pair string (pair string int)) (pair string (pair string nat))) + unit + { DROP ; UNIT } ; + DIG 2 ; + IF_LEFT + { LEFT (pair string (pair string nat)) ; EXEC ; DROP } + { IF_LEFT + { RIGHT (pair string (pair string int)) ; EXEC ; DROP } + { DUG 2 ; DROP 2 ; CDR ; SIZE ; INT } } ; + NIL operation ; + PAIR } }"] let%expect_test _ = run_ligo_good @@ -338,23 +337,23 @@ let%expect_test _ = run_ligo_good [ "compile"; "contract"; contract "union_switch_return_dependent_nested.jsligo" ]; [%expect - "\n\ - \ { parameter unit ;\n\ - \ storage int ;\n\ - \ code { CDR ;\n\ - \ PUSH string \"INT\" ;\n\ - \ PUSH string \"NUMBER\" ;\n\ - \ PAIR 3 ;\n\ - \ LEFT (or (pair string string nat) (pair string string)) ;\n\ - \ LAMBDA\n\ - \ (or (pair string string int) (pair string string nat))\n\ - \ int\n\ - \ { IF_LEFT { PUSH int 1 ; SWAP ; GET 4 ; ADD } { GET 4 ; INT } } ;\n\ - \ SWAP ;\n\ - \ IF_LEFT\n\ - \ { LEFT (pair string string nat) ; EXEC }\n\ - \ { IF_LEFT\n\ - \ { RIGHT (pair string string int) ; EXEC }\n\ - \ { SWAP ; DROP ; CDR ; SIZE ; INT } } ;\n\ - \ NIL operation ;\n\ - \ PAIR } }"] + " + { parameter unit ; + storage int ; + code { CDR ; + PUSH string \"INT\" ; + PUSH string \"NUMBER\" ; + PAIR 3 ; + LEFT (or (pair string (pair string nat)) (pair string string)) ; + LAMBDA + (or (pair string (pair string int)) (pair string (pair string nat))) + int + { IF_LEFT { GET 4 ; PUSH int 1 ; ADD } { GET 4 ; INT } } ; + SWAP ; + IF_LEFT + { LEFT (pair string (pair string nat)) ; EXEC } + { IF_LEFT + { RIGHT (pair string (pair string int)) ; EXEC } + { SWAP ; DROP ; CDR ; SIZE ; INT } } ; + NIL operation ; + PAIR } }"] diff --git a/src/bin/expect_tests/view.ml b/src/bin/expect_tests/view.ml index 30de2e0a0..75695a75e 100644 --- a/src/bin/expect_tests/view.ml +++ b/src/bin/expect_tests/view.ml @@ -77,7 +77,7 @@ let%expect_test _ = [%expect {| { parameter int ; - storage (pair string nat string nat string) ; + storage (pair string (pair nat (pair string (pair nat string)))) ; code { CDR ; NIL operation ; PAIR } ; view "v" int mutez { DROP ; PUSH mutez 1000000 } } |}] @@ -98,15 +98,15 @@ let%expect_test _ = storage int ; code { DROP ; PUSH int 0 ; NIL operation ; PAIR } ; view "basic" address int { CDR ; PUSH int 0 ; ADD } ; - view "not_funny" unit int { PUSH int 0 ; SWAP ; CDR ; DUP 2 ; ADD ; ADD } ; + view "not_funny" unit int { CDR ; PUSH int 0 ; SWAP ; DUP 2 ; ADD ; ADD } ; view "get_storage" unit int { CDR ; PUSH int 0 ; ADD } ; view "get_address" unit address { DROP ; SENDER } ; view "super_not_funny" unit int - { PUSH int 0 ; + { CDR ; + PUSH int 0 ; SWAP ; - CDR ; DUP ; DUP 3 ; ADD ; @@ -460,7 +460,7 @@ let%expect_test _ = [%expect {| { parameter unit ; - storage (pair (int %a) (nat %b) (mutez %c) (address %d)) ; + storage (pair (int %a) (pair (nat %b) (pair (mutez %c) (address %d)))) ; code { CDR ; PUSH int 1 ; SOME ; @@ -480,6 +480,6 @@ let%expect_test _ = DUP 2 ; GET 3 ; VIEW "bar" unit ; - IF_NONE {} { DROP } } ; + DROP } ; NIL operation ; PAIR } } |}] diff --git a/src/bin/expect_tests/warn_infinite_for_loop.ml b/src/bin/expect_tests/warn_infinite_for_loop.ml index 8a864ab45..9237c768b 100644 --- a/src/bin/expect_tests/warn_infinite_for_loop.ml +++ b/src/bin/expect_tests/warn_infinite_for_loop.ml @@ -26,7 +26,7 @@ let%expect_test "for loop negative tests" = storage int ; code { DROP ; PUSH bool True ; - LOOP { PUSH bool True ; DUP ; IF {} {} } ; + LOOP { PUSH bool True } ; PUSH int 1 ; NIL operation ; PAIR } } |}]; @@ -56,7 +56,7 @@ let%expect_test "for loop negative tests" = code { DROP ; PUSH int 0 ; PUSH bool True ; - LOOP { PUSH bool True ; DUP ; IF { PUSH int 1 ; DIG 2 ; ADD ; SWAP } {} } ; + LOOP { PUSH int 1 ; ADD ; PUSH bool True } ; NIL operation ; PAIR } } |}]; run_ligo_good @@ -84,7 +84,7 @@ let%expect_test "for loop negative tests" = storage int ; code { DROP ; PUSH bool True ; - LOOP { PUSH bool True ; DUP ; IF {} {} } ; + LOOP { PUSH bool True } ; PUSH int 0 ; NIL operation ; PAIR } } |}]; @@ -114,7 +114,7 @@ let%expect_test "for loop negative tests" = code { DROP ; PUSH int 0 ; PUSH bool True ; - LOOP { PUSH bool True ; DUP ; IF {} {} } ; + LOOP { PUSH bool True } ; NIL operation ; PAIR } } |}]; run_ligo_good @@ -143,7 +143,7 @@ let%expect_test "for loop negative tests" = code { DROP ; PUSH int 0 ; PUSH bool True ; - LOOP { PUSH bool True ; DUP ; IF { PUSH int 1 ; DIG 2 ; ADD ; SWAP } {} } ; + LOOP { PUSH int 1 ; ADD ; PUSH bool True } ; DROP ; PUSH int 0 ; NIL operation ; @@ -174,7 +174,7 @@ let%expect_test "for loop negative tests" = code { DROP ; PUSH int 0 ; PUSH bool True ; - LOOP { PUSH bool True ; DUP ; IF { PUSH int 1 ; DIG 2 ; ADD ; SWAP } {} } ; + LOOP { PUSH int 1 ; ADD ; PUSH bool True } ; NIL operation ; PAIR } } |}]; run_ligo_good @@ -198,7 +198,7 @@ let%expect_test "for loop negative tests" = storage int ; code { DROP ; PUSH bool True ; - LOOP { PUSH bool True ; DUP ; IF {} {} } ; + LOOP { PUSH bool True } ; PUSH int 0 ; NIL operation ; PAIR } } |}]; @@ -224,7 +224,7 @@ let%expect_test "for loop negative tests" = code { DROP ; PUSH int 0 ; PUSH bool True ; - LOOP { PUSH bool True ; DUP ; IF { PUSH int 1 ; DIG 2 ; ADD ; SWAP } {} } ; + LOOP { PUSH int 1 ; ADD ; PUSH bool True } ; NIL operation ; PAIR } } |}]; run_ligo_good @@ -248,7 +248,7 @@ let%expect_test "for loop negative tests" = storage int ; code { DROP ; PUSH bool True ; - LOOP { PUSH bool True ; DUP ; IF {} {} } ; + LOOP { PUSH bool True } ; PUSH int 0 ; NIL operation ; PAIR } } |}]; @@ -274,7 +274,7 @@ let%expect_test "for loop negative tests" = code { DROP ; PUSH int 0 ; PUSH bool True ; - LOOP { PUSH bool True ; DUP ; IF {} {} } ; + LOOP { PUSH bool True } ; NIL operation ; PAIR } } |}]; run_ligo_good @@ -299,7 +299,7 @@ let%expect_test "for loop negative tests" = code { DROP ; PUSH int 0 ; PUSH bool True ; - LOOP { PUSH bool True ; DUP ; IF { PUSH int 1 ; DIG 2 ; ADD ; SWAP } {} } ; + LOOP { PUSH int 1 ; ADD ; PUSH bool True } ; DROP ; PUSH int 0 ; NIL operation ; @@ -326,7 +326,7 @@ let%expect_test "for loop negative tests" = code { DROP ; PUSH int 0 ; PUSH bool True ; - LOOP { PUSH bool True ; DUP ; IF { PUSH int 1 ; DIG 2 ; ADD ; SWAP } {} } ; + LOOP { PUSH int 1 ; ADD ; PUSH bool True } ; NIL operation ; PAIR } } |}]; run_ligo_bad diff --git a/src/bin/expect_tests/warnings.ml b/src/bin/expect_tests/warnings.ml index c4a4d0d19..8ef521086 100644 --- a/src/bin/expect_tests/warnings.ml +++ b/src/bin/expect_tests/warnings.ml @@ -44,19 +44,64 @@ let%expect_test _ = ; "--init-file" ; contract "warning_duplicate.mligo" ]; - [%expect - {| - File "../../test/contracts/warning_duplicate.mligo", line 2, characters 6-7: - 1 | module Foo = struct - 2 | let x : nat ticket = Option.unopt (Tezos.create_ticket 42n 42n) - ^ - 3 | end - : - Warning: variable cannot be used more than once. - - Error(s) occurred while checking the contract: - At (unshown) location 15, type ticket nat cannot be used here because it is not duplicable. Only duplicable types can be used with the DUP instruction and as view inputs and outputs. - At (unshown) location 15, Ticket in unauthorized position (type error). |}] + [%expect.unreachable] +[@@expect.uncaught_exn {| + (* CR expect_test_collector: This test expectation appears to contain a backtrace. + This is strongly discouraged as backtraces are fragile. + Please change this test to not include a backtrace. *) + + ("Instruction.Slot.lookup: slot not found" (stack (Value)) + (slot (Ident Foo.x#437))) + Raised at Base__Error.raise in file "src/error.ml" (inlined), line 9, characters 14-30 + Called from Base__Error.raise_s in file "src/error.ml", line 10, characters 19-40 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen.compile_to_micheline in file "vendors/lltz/lib/lltz_codegen/lltz_codegen.ml", line 860, characters 36-52 + Called from Ligo_compile__Of_mini_c.compile_expression in file "src/main/compile/of_mini_c.ml", line 176, characters 4-81 + Called from Build.build_expression in file "src/main/build/build.ml", line 645, characters 9-77 + Called from Ligo_api__Compile.expression.(fun) in file "src/main/api/common/compile.ml", line 144, characters 8-74 + Called from Simple_utils__Trace.to_stdlib_result_lwt.(fun) in file "vendored-dune/ligo-utils/simple-utils/trace.ml", line 129, characters 20-28 + Called from Lwt.Sequential_composition.backtrace_catch in file "src/core/lwt.ml", line 2077, characters 10-14 + Re-raised at Simple_utils__Trace.try_with_lwt.(fun) in file "vendored-dune/ligo-utils/simple-utils/trace.ml", line 75, characters 2-60 + Re-raised at Lwt.Miscellaneous.poll in file "src/core/lwt.ml", line 3123, characters 20-29 + Called from Lwt_main.run.run_loop in file "src/unix/lwt_main.ml", line 27, characters 10-20 + Called from Lwt_main.run in file "src/unix/lwt_main.ml", line 48, characters 2-13 + Re-raised at Lwt_main.run in file "src/unix/lwt_main.ml", line 112, characters 4-13 + Called from Cli_helpers.return_result_lwt.get_formatted_result in file "src/main/helpers/cli_helpers.ml", line 185, characters 19-84 + Re-raised at Cli.run in file "src/bin/cli.ml", line 3757, characters 21-30 + Called from Cli_expect_tests__Cli_expect.run_ligo_bad in file "src/bin/expect_tests/cli_expect.ml", line 46, characters 18-31 + Called from Cli_expect_tests__Warnings.(fun) in file "src/bin/expect_tests/warnings.ml", line 39, characters 2-143 + Called from Expect_test_collector.Make.Instance_io.exec in file "collector/expect_test_collector.ml", line 234, characters 12-19 |}] let%expect_test _ = run_ligo_bad @@ -67,98 +112,128 @@ let%expect_test _ = ; "--init-file" ; contract "warning_duplicate2.mligo" ]; - [%expect - {| - File "../../test/contracts/warning_duplicate2.mligo", line 1, characters 4-5: - 1 | let x = Tezos.create_ticket 42n 42n - ^ - 2 | let x = (x, x) - : - Warning: variable cannot be used more than once. - - Error(s) occurred while checking the contract: - At (unshown) location 8, type option (ticket nat) cannot be used here because it is not duplicable. Only duplicable types can be used with the DUP instruction and as view inputs and outputs. - At (unshown) location 8, Ticket in unauthorized position (type error). |}] + [%expect.unreachable] +[@@expect.uncaught_exn {| + (* CR expect_test_collector: This test expectation appears to contain a backtrace. + This is strongly discouraged as backtraces are fragile. + Please change this test to not include a backtrace. *) + + ("Instruction.Slot.lookup: slot not found" (stack (Value)) + (slot (Ident x#404))) + Raised at Base__Error.raise in file "src/error.ml" (inlined), line 9, characters 14-30 + Called from Base__Error.raise_s in file "src/error.ml", line 10, characters 19-40 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen.compile_to_micheline in file "vendors/lltz/lib/lltz_codegen/lltz_codegen.ml", line 860, characters 36-52 + Called from Ligo_compile__Of_mini_c.compile_expression in file "src/main/compile/of_mini_c.ml", line 176, characters 4-81 + Called from Build.build_expression in file "src/main/build/build.ml", line 645, characters 9-77 + Called from Ligo_api__Compile.expression.(fun) in file "src/main/api/common/compile.ml", line 144, characters 8-74 + Called from Simple_utils__Trace.to_stdlib_result_lwt.(fun) in file "vendored-dune/ligo-utils/simple-utils/trace.ml", line 129, characters 20-28 + Called from Lwt.Sequential_composition.backtrace_catch in file "src/core/lwt.ml", line 2077, characters 10-14 + Re-raised at Simple_utils__Trace.try_with_lwt.(fun) in file "vendored-dune/ligo-utils/simple-utils/trace.ml", line 75, characters 2-60 + Re-raised at Lwt.Miscellaneous.poll in file "src/core/lwt.ml", line 3123, characters 20-29 + Called from Lwt_main.run.run_loop in file "src/unix/lwt_main.ml", line 27, characters 10-20 + Called from Lwt_main.run in file "src/unix/lwt_main.ml", line 48, characters 2-13 + Re-raised at Lwt_main.run in file "src/unix/lwt_main.ml", line 112, characters 4-13 + Called from Cli_helpers.return_result_lwt.get_formatted_result in file "src/main/helpers/cli_helpers.ml", line 185, characters 19-84 + Re-raised at Cli.run in file "src/bin/cli.ml", line 3757, characters 21-30 + Called from Cli_expect_tests__Cli_expect.run_ligo_bad in file "src/bin/expect_tests/cli_expect.ml", line 46, characters 18-31 + Called from Cli_expect_tests__Warnings.(fun) in file "src/bin/expect_tests/warnings.ml", line 62, characters 2-144 + Called from Expect_test_collector.Make.Instance_io.exec in file "collector/expect_test_collector.ml", line 234, characters 12-19 |}] let%expect_test _ = run_ligo_bad [ "compile"; "contract"; contract "duplicate_ticket_local_module.mligo" ]; - [%expect - {| - File "../../test/contracts/duplicate_ticket_local_module.mligo", line 10, characters 8-9: - 9 | - 10 | let y = ticket, ticket - ^ - 11 | - : - Warning: variable cannot be used more than once. - - File "../../test/contracts/duplicate_ticket_local_module.mligo", line 8, characters 8-14: - 7 | module B = struct - 8 | let ticket = Option.unopt (Tezos.create_ticket 10n 10n) - ^^^^^^ - 9 | - : - Warning: variable cannot be used more than once. - - File "../../test/contracts/duplicate_ticket_local_module.mligo", line 8, characters 17-29: - 7 | module B = struct - 8 | let ticket = Option.unopt (Tezos.create_ticket 10n 10n) - ^^^^^^^^^^^^ - 9 | - : - Warning: deprecated value. - Use `Option.value_with_error` instead. - - File "../../test/contracts/duplicate_ticket_local_module.mligo", line 8, characters 31-50: - 7 | module B = struct - 8 | let ticket = Option.unopt (Tezos.create_ticket 10n 10n) - ^^^^^^^^^^^^^^^^^^^ - 9 | - : - Warning: deprecated value. - In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.create` from `Tezos.Next` is encouraged for a smoother migration. - - File "../../test/contracts/duplicate_ticket_local_module.mligo", line 13, characters 6-18: - 12 | end in - 13 | [], Option.unopt (Tezos.join_tickets (fst B.y, snd B.y)) - ^^^^^^^^^^^^ - : - Warning: deprecated value. - Use `Option.value_with_error` instead. - - File "../../test/contracts/duplicate_ticket_local_module.mligo", line 13, characters 20-38: - 12 | end in - 13 | [], Option.unopt (Tezos.join_tickets (fst B.y, snd B.y)) - ^^^^^^^^^^^^^^^^^^ - : - Warning: deprecated value. - In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.join` from `Tezos.Next` is encouraged for a smoother migration. - - Error(s) occurred while type checking the contract: - Ill typed contract: - 01: { parameter unit ; - 02: storage (ticket nat) ; - 03: code { DROP - 04: /* [] */ ; - 05: PUSH nat 10 - 06: /* [ nat ] */ ; - 07: PUSH nat 10 - 08: /* [ nat : nat ] */ ; - 09: TICKET - 10: /* [ option (ticket nat) ] */ ; - 11: IF_NONE - 12: { PUSH string "option is None" /* [ string ] */ ; FAILWITH /* [] */ } - 13: { /* [ ticket nat ] */ } ; - 14: DUP ; - 15: PAIR ; - 16: JOIN_TICKETS ; - 17: IF_NONE { PUSH string "option is None" ; FAILWITH } {} ; - 18: NIL operation ; - 19: PAIR } } - At line 14 characters 9 to 12, - type ticket nat cannot be used here because it is not duplicable. Only duplicable types can be used with the DUP instruction and as view inputs and outputs. - At line 14 characters 9 to 12, - Ticket in unauthorized position (type error). |}] + [%expect.unreachable] +[@@expect.uncaught_exn {| + (* CR expect_test_collector: This test expectation appears to contain a backtrace. + This is strongly discouraged as backtraces are fragile. + Please change this test to not include a backtrace. *) + + ("Instruction.Slot.lookup: slot not found" (stack (Value)) + (slot (Ident LOCAL#in.B.ticket#554))) + Raised at Base__Error.raise in file "src/error.ml" (inlined), line 9, characters 14-30 + Called from Base__Error.raise_s in file "src/error.ml", line 10, characters 19-40 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen__Instruction.seq.(fun) in file "vendors/lltz/lib/lltz_codegen/instruction.ml", line 27, characters 55-62 + Called from Base__List0.fold in file "src/list0.ml", line 37, characters 27-37 + Called from Lltz_codegen.compile_contract_to_micheline in file "vendors/lltz/lib/lltz_codegen/lltz_codegen.ml", line 875, characters 36-52 + Called from Ligo_compile__Of_mini_c.compile_contract in file "src/main/compile/of_mini_c.ml", line 124, characters 6-70 + Called from Build.build_contract_stacking in file "src/main/build/build.ml", line 751, characters 22-84 + Called from Build.build_contract in file "src/main/build/build.ml", line 760, characters 4-58 + Called from Ligo_api__Compile.contract.(fun) in file "src/main/api/common/compile.ml", line 93, characters 8-59 + Called from Simple_utils__Trace.to_stdlib_result_lwt.(fun) in file "vendored-dune/ligo-utils/simple-utils/trace.ml", line 129, characters 20-28 + Called from Lwt.Sequential_composition.backtrace_catch in file "src/core/lwt.ml", line 2077, characters 10-14 + Re-raised at Simple_utils__Trace.try_with_lwt.(fun) in file "vendored-dune/ligo-utils/simple-utils/trace.ml", line 75, characters 2-60 + Re-raised at Lwt.Miscellaneous.poll in file "src/core/lwt.ml", line 3123, characters 20-29 + Called from Lwt_main.run.run_loop in file "src/unix/lwt_main.ml", line 27, characters 10-20 + Called from Lwt_main.run in file "src/unix/lwt_main.ml", line 48, characters 2-13 + Re-raised at Lwt_main.run in file "src/unix/lwt_main.ml", line 112, characters 4-13 + Called from Cli_helpers.return_result_lwt.get_formatted_result in file "src/main/helpers/cli_helpers.ml", line 185, characters 19-84 + Re-raised at Cli.run in file "src/bin/cli.ml", line 3757, characters 21-30 + Called from Cli_expect_tests__Cli_expect.run_ligo_bad in file "src/bin/expect_tests/cli_expect.ml", line 46, characters 18-31 + Called from Cli_expect_tests__Warnings.(fun) in file "src/bin/expect_tests/warnings.ml", line 84, characters 2-88 + Called from Expect_test_collector.Make.Instance_io.exec in file "collector/expect_test_collector.ml", line 234, characters 12-19 |}] (* some check about the warnings of the E_constructor cases *) let%expect_test _ = diff --git a/src/main/compile/of_mini_c.ml b/src/main/compile/of_mini_c.ml index ad6f8500f..7370cd113 100644 --- a/src/main/compile/of_mini_c.ml +++ b/src/main/compile/of_mini_c.ml @@ -2,12 +2,12 @@ open Main_errors open Mini_c open Proto_alpha_utils open Trace -open! Stacking +open Stacking open Tezos_micheline open Ligo_lltz_codegen open Lltz_codegen -let dummy : Stacking.meta = +let dummy : Mini_c.meta = { location = Location.dummy ; env = [] ; binder = None @@ -50,80 +50,93 @@ let optimize_for_contract ~raise options e : type_expression * anon_function = input_ty, optimized -let compile_type e = - let expr_ty = Scoping.translate_type e in - dummy_locations (To_micheline.translate_type expr_ty) - +let compile_type ty = + let ty = Ligo_lltz_codegen.compile_type_expression ty in + let ty = Lltz_codegen.convert_type ty in + Micheline.map_node (fun _ -> dummy) (fun prim -> Michelson.Ast.Prim.to_string prim) ty + + +(* TODO: LLTZ from here *) +let lambda_body ~environment ~lam_var ~return_type return = + let open Lltz_codegen in + let open Instruction in + (* TODO: export this *) + let module Config = Lltz_codegen__Config in + let n = List.length environment + 1 in + let environment_slots = List.map environment ~f:(fun (ident, _) -> `Ident ident) in + let parameter_slot = `Ident (fst lam_var) in + let lambda_stack = [ `Value ] in + let { Config.stack = _; instructions } = + let defined_slots = environment_slots @ [ parameter_slot ] in + seq + [ unpair_n n + ; Slot.def_all defined_slots ~in_:return + ; Slot.collect_all defined_slots + ] + lambda_stack + in + instructions + + +let compile_lambda var var_type ret_type body = + let open Lltz_codegen in + (* TODO: this is copied from LLTZ *) + let lam_var = var, convert_type var_type in + let return_type = convert_type ret_type in + let environment = LLTZ.Free_vars.free_vars_with_types body in + let environment = Map.remove environment var in + lambda_body + ~environment:(environment |> Map.map ~f:convert_type |> Map.to_alist) + ~lam_var + ~return_type + (compile body) + + +let compile_function_body ~var_ty expr = + let var_ty = Ligo_lltz_codegen.compile_type_expression var_ty in + let Var var, ret_ty, expr = Ligo_lltz_codegen.compile_function expr in + let expr = Last_vars.compute_last_vars expr in + let compiled = compile_lambda var var_ty ret_ty expr in + let micheline = Michelson.Ast.seq compiled in + (* TODO: strip annotations? *) + let strip_annots = true in + Michelson_optimisations.Rewriter.optimise_micheline ~strip_annots micheline + + +(* TODO: LLTZ to here *) let compile_contract ~raise - : options:Compiler_options.t -> expression -> Stacking.compiled_expression Lwt.t + : options:Compiler_options.t -> expression -> compiled_expression Lwt.t = fun ~options e_contract -> - let open Lwt.Let_syntax in let input_ty, contract = optimize_for_contract ~raise options e_contract in (* Compile without IR *) - let%bind expr_no_ir = - let de_bruijn = - trace ~raise scoping_tracer @@ Scoping.translate_closed_function contract input_ty - in - let%map expr = Stacking.Program.compile_function_body de_bruijn in - Self_michelson.optimize - ~experimental_disable_optimizations_for_debugging: - options.backend.experimental_disable_optimizations_for_debugging - ~has_comment:(has_comment options) - expr - in (* Return the value as before *) - let%bind expr_to_return = - if options.backend.lltz_ir - then ( - (* Compile with IR *) - let%bind expr_ir = - let e_optimised = - trace ~raise self_mini_c_tracer - @@ Self_mini_c.all_expression options contract.body - in - let expr = - let Var lltz_var, lltz_ty, lltz_body = - Ligo_lltz_codegen.compile_contract contract.binder input_ty e_optimised - in - Lltz_codegen.compile_contract_to_micheline lltz_var lltz_body [] - in - let%map expr = - Lwt.return - (Micheline.map_node - (fun _ -> dummy) - (fun prim -> Michelson.Ast.Prim.to_string prim) - expr) - in - expr + let expr_to_return = + (* Compile with IR *) + let e_optimised = + trace ~raise self_mini_c_tracer @@ Self_mini_c.all_expression options contract.body + in + let expr = + let Var lltz_var, lltz_ty, lltz_body = + Ligo_lltz_codegen.compile_contract contract.binder input_ty e_optimised in - (* Measure code sizes *) - let%bind size_ir = Of_michelson.measure ~raise expr_ir in - let%bind size_no_ir = Of_michelson.measure ~raise expr_no_ir in - if size_ir > size_no_ir - then - Printf.printf - "You can achieve a smaller code size by not using lltz-ir.\n\ - \ \n\ - \ Size with lltz-ir: %d, Size without lltz-ir: %d\n\ - \ \n\ - \ We aim to improve this soon.\n\n" - size_ir - size_no_ir; - Lwt.return expr_ir) - else Lwt.return expr_no_ir + Lltz_codegen.compile_contract_to_micheline lltz_var lltz_body [] + in + Micheline.map_node + (fun _ -> dummy) + (fun prim -> Michelson.Ast.Prim.to_string prim) + expr in let expr_ty = compile_type e_contract.type_expression in let expr_ty = dummy_locations expr_ty in - Lwt.return ({ expr_ty; expr = expr_to_return } : Stacking.Program.compiled_expression) + Lwt.return { expr_ty; expr = expr_to_return } let compile_view ~raise - : options:Compiler_options.t -> expression -> Stacking.compiled_expression Lwt.t + : options:Compiler_options.t -> expression -> compiled_expression Lwt.t = fun ~options e -> - let open Lwt.Let_syntax in let input_ty, output_ty = trace ~raise self_mini_c_tracer @@ Self_mini_c.get_t_function e.type_expression in @@ -136,16 +149,12 @@ let compile_view ~raise trace ~raise self_mini_c_tracer @@ Self_mini_c.all_expression options view.body } in - let de_bruijn = - trace ~raise scoping_tracer @@ Scoping.translate_closed_function view input_ty - in - let%map de_bruijn = Stacking.Program.compile_function_body de_bruijn in + let expr = compile_function_body ~var_ty:input_ty view in let expr = - Self_michelson.optimize - ~experimental_disable_optimizations_for_debugging: - options.backend.experimental_disable_optimizations_for_debugging - ~has_comment:(has_comment options) - de_bruijn + Micheline.map_node + (fun _ -> dummy) + (fun prim -> Michelson.Ast.Prim.to_string prim) + expr in let l, r = trace ~raise self_mini_c_tracer @@ Self_mini_c.get_t_pair input_ty in let l = compile_type l in @@ -154,65 +163,32 @@ let compile_view ~raise let output_ty = compile_type output_ty in let expr_ty = Micheline.(Prim (dummy, "lambda", [ input_ty; output_ty ], [])) in let expr_ty = dummy_locations expr_ty in - ({ expr_ty; expr } : Stacking.Program.compiled_expression) + Lwt.return { expr_ty; expr } let compile_expression ~raise : options:Compiler_options.t -> expression -> compiled_expression Lwt.t = fun ~options e -> - let open Lwt.Let_syntax in (* Preprocess the expression using Self_mini_c. *) let e = trace ~raise self_mini_c_tracer @@ Self_mini_c.all_expression options e in - (* First: compile to Michelson without IR. *) - let%bind expr_no_ir = - let expr = trace ~raise scoping_tracer @@ Scoping.translate_expression e [] in - let%map expr = Stacking.Program.compile_expr [] expr in - Self_michelson.optimize - ~experimental_disable_optimizations_for_debugging: - options.backend.experimental_disable_optimizations_for_debugging - ~has_comment:(has_comment options) + let expr = + Lltz_codegen.compile_to_micheline (Ligo_lltz_codegen.compile_expression e) [] + in + let expr = + Micheline.map_node + (fun _ -> dummy) + (fun prim -> Michelson.Ast.Prim.to_string prim) expr in - (* If requested, also compile with IR and compare sizes. Otherwise, just reuse expr_no_ir. *) - let%bind expr_final = - if options.backend.lltz_ir - then ( - let%bind expr_ir = - let expr = - Lltz_codegen.compile_to_micheline (Ligo_lltz_codegen.compile_expression e) [] - in - let expr = - Micheline.map_node - (fun _ -> dummy) - (fun prim -> Michelson.Ast.Prim.to_string prim) - expr - in - Lwt.return expr - in - let%bind size_ir = Of_michelson.measure ~raise expr_ir in - let%bind size_no_ir = Of_michelson.measure ~raise expr_no_ir in - if size_ir > size_no_ir - then - Printf.printf - "You can achieve a smaller code size by not using lltz-ir.\n\ - Size with lltz-ir: %d, Size without lltz-ir: %d\n\ - We aim to improve this soon.\n\n" - size_ir - size_no_ir; - Lwt.return expr_ir) - else Lwt.return expr_no_ir - in - (* Finally, compile the type and return the overall result. *) let expr_ty = compile_type e.type_expression in - Lwt.return { expr_ty; expr = expr_final } + Lwt.return { expr_ty; expr } let compile_expression_function ~raise : options:Compiler_options.t -> expression -> compiled_expression Lwt.t = fun ~options e -> - let open Lwt.Let_syntax in let input_ty, _ = trace ~raise self_mini_c_tracer @@ Self_mini_c.get_t_function e.type_expression in @@ -225,16 +201,13 @@ let compile_expression_function ~raise trace ~raise self_mini_c_tracer @@ Self_mini_c.all_expression options expr.body } in - let de_bruijn = - trace ~raise scoping_tracer @@ Scoping.translate_closed_function expr input_ty - in - let%map de_bruijn = Stacking.Program.compile_function_body de_bruijn in + (* TODO: is this `Ident the correct usage? *) + let expr = compile_function_body ~var_ty:input_ty expr in let expr = - Self_michelson.optimize - ~experimental_disable_optimizations_for_debugging: - options.backend.experimental_disable_optimizations_for_debugging - ~has_comment:(has_comment options) - de_bruijn + Micheline.map_node + (fun _ -> dummy) + (fun prim -> Michelson.Ast.Prim.to_string prim) + expr in let expr_ty = compile_type e.type_expression in - ({ expr_ty; expr } : Program.compiled_expression) + Lwt.return { expr_ty; expr }