From fb8fae05d74087bbd4cf1b68300cb2cc32f0c7ab Mon Sep 17 00:00:00 2001 From: John David Pressman Date: Mon, 16 Dec 2019 12:10:31 -0800 Subject: [PATCH] Fix IMPLICIT_ACCOUNT, again and this time add regression expect test --- src/bin/expect_tests/contract_tests.ml | 13 +++++++++++++ src/passes/operators/operators.ml | 1 + src/test/contracts/implicit.mligo | 3 +++ 3 files changed, 17 insertions(+) create mode 100644 src/test/contracts/implicit.mligo diff --git a/src/bin/expect_tests/contract_tests.ml b/src/bin/expect_tests/contract_tests.ml index 7492ce39d..1facce834 100644 --- a/src/bin/expect_tests/contract_tests.ml +++ b/src/bin/expect_tests/contract_tests.ml @@ -899,3 +899,16 @@ let%expect_test _ = PAIR ; DIP { DROP 5 } } ; DIP { DROP } } } |}] + +let%expect_test _ = + run_ligo_good [ "compile-contract" ; contract "implicit.mligo" ; "main" ] ; + [%expect {| + { parameter key_hash ; + storage unit ; + code { DUP ; + CAR ; + IMPLICIT_ACCOUNT ; + UNIT ; + NIL operation ; + PAIR ; + DIP { DROP 2 } } } |}] diff --git a/src/passes/operators/operators.ml b/src/passes/operators/operators.ml index 40ee08dd4..3ac7a0959 100644 --- a/src/passes/operators/operators.ml +++ b/src/passes/operators/operators.ml @@ -922,6 +922,7 @@ module Compiler = struct | C_AMOUNT -> ok @@ simple_constant @@ prim I_AMOUNT | C_ADDRESS -> ok @@ simple_constant @@ prim I_ADDRESS | C_SELF_ADDRESS -> ok @@ simple_constant @@ seq [prim I_SELF; prim I_ADDRESS] + | C_IMPLICIT_ACCOUNT -> ok @@ simple_unary @@ prim I_IMPLICIT_ACCOUNT | C_NOW -> ok @@ simple_constant @@ prim I_NOW | C_CALL -> ok @@ simple_ternary @@ prim I_TRANSFER_TOKENS | C_SOURCE -> ok @@ simple_constant @@ prim I_SOURCE diff --git a/src/test/contracts/implicit.mligo b/src/test/contracts/implicit.mligo new file mode 100644 index 000000000..c20f45546 --- /dev/null +++ b/src/test/contracts/implicit.mligo @@ -0,0 +1,3 @@ +let main (p : key_hash) (s : unit) = + let c : unit contract = Current.implicit_account p in + (([] : operation list), unit) \ No newline at end of file