diff --git a/src/passes/operators/operators.ml b/src/passes/operators/operators.ml index 3ac7a0959..abb7a3339 100644 --- a/src/passes/operators/operators.ml +++ b/src/passes/operators/operators.ml @@ -920,7 +920,7 @@ module Compiler = struct | C_UNIT -> ok @@ simple_constant @@ prim I_UNIT | C_BALANCE -> ok @@ simple_constant @@ prim I_BALANCE | C_AMOUNT -> ok @@ simple_constant @@ prim I_AMOUNT - | C_ADDRESS -> ok @@ simple_constant @@ prim I_ADDRESS + | C_ADDRESS -> ok @@ simple_unary @@ 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 diff --git a/src/test/contracts/address.ligo b/src/test/contracts/address.ligo index 555ab6fe7..2113bc7ac 100644 --- a/src/test/contracts/address.ligo +++ b/src/test/contracts/address.ligo @@ -1 +1,5 @@ -function main (const c: contract(unit)) : address is address(c) +// function main (const c: contract(unit)) : address is address(c) + +function main (const p : key_hash) : address is block { + const c : contract(unit) = implicit_account(p) ; +} with address(c) \ No newline at end of file diff --git a/src/test/contracts/address.mligo b/src/test/contracts/address.mligo index efca3d8b8..3651ea223 100644 --- a/src/test/contracts/address.mligo +++ b/src/test/contracts/address.mligo @@ -1 +1,3 @@ -let main (c: unit contract) : address = Current.address c +let main (p : key_hash) = + let c : unit contract = Current.implicit_account p in + Current.address c \ No newline at end of file diff --git a/src/test/contracts/address.religo b/src/test/contracts/address.religo index 1bab0004b..df1742ce1 100644 --- a/src/test/contracts/address.religo +++ b/src/test/contracts/address.religo @@ -1 +1,4 @@ -let main = (c: contract(unit)): address => Current.address(c); +let main = (p : key_hash) : address => { + let c : contract(unit) = Current.implicit_account(p) ; + Current.address(c) ; +}; diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 921a6a376..14cc41e23 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -1624,17 +1624,26 @@ let balance_constant_religo () : unit result = expect_eq program "main" input expected +let addr_test program = + let open Proto_alpha_utils.Memory_proto_alpha in + let addr = Protocol.Alpha_context.Contract.to_b58check @@ + (List.nth dummy_environment.identities 0).implicit_contract in + let open Tezos_crypto in + let key_hash = Signature.Public_key_hash.to_b58check @@ + (List.nth dummy_environment.identities 0).public_key_hash in + expect_eq program "main" (e_key_hash key_hash) (e_address addr) + let address () : unit result = - let%bind _ = type_file "./contracts/address.ligo" in - ok () + let%bind program = type_file "./contracts/address.ligo" in + addr_test program let address_mligo () : unit result = - let%bind _ = mtype_file "./contracts/address.mligo" in - ok () + let%bind program = mtype_file "./contracts/address.mligo" in + addr_test program let address_religo () : unit result = - let%bind _ = retype_file "./contracts/address.religo" in - ok () + let%bind program = retype_file "./contracts/address.religo" in + addr_test program let self_address () : unit result =