diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index f673607..f0fee08 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -500,7 +500,13 @@ global_env() -> ], var_args, A))}, {"clone", Stateful( FunN([ {named_arg_t, Ann, {id, Ann, "gas"}, Int, - {qid, Ann, ["Call","gas_left"]}} + {typed, Ann, + {app, Ann, + {typed, Ann, {qid, Ann, ["Call","gas_left"]}, + typesig_to_fun_t(Fun([], Int)) + }, + []}, Int + }} , {named_arg_t, Ann, {id, Ann, "value"}, Int, {typed, Ann, {int, Ann, 0}, Int}} , {named_arg_t, Ann, {id, Ann, "protected"}, Bool, {typed, Ann, {bool, Ann, false}, Bool}} , {named_arg_t, Ann, {id, Ann, "ref"}, A, undefined} diff --git a/src/aeso_fcode_to_fate.erl b/src/aeso_fcode_to_fate.erl index f27405a..a296001 100644 --- a/src/aeso_fcode_to_fate.erl +++ b/src/aeso_fcode_to_fate.erl @@ -580,9 +580,18 @@ builtin_to_scode(Env, chain_bytecode_hash, [_Addr] = Args) -> call_to_scode(Env, aeb_fate_ops:bytecode_hash(?a, ?a), Args); builtin_to_scode(Env, chain_clone, [TypeRep, GasCap, Value, Prot, Contract | InitArgs]) -> - call_to_scode(Env, aeb_fate_ops:clone_g(?a, ?a, ?a, ?a, ?a), - [Contract, TypeRep, Value, GasCap, Prot | InitArgs] - ); + case GasCap of + {builtin, call_gas_left, _} -> + call_to_scode(Env, aeb_fate_ops:clone(?a, ?a, ?a, ?a), + [Contract, TypeRep, Value, Prot | InitArgs] + ); + _ -> + io:format("\n\n************* GAS CAP: ~p\n\n", [GasCap]), + call_to_scode(Env, aeb_fate_ops:clone_g(?a, ?a, ?a, ?a, ?a), + [Contract, TypeRep, Value, GasCap, Prot | InitArgs] + ) + end; + builtin_to_scode(Env, chain_create, [ Code, TypeRep, Value | InitArgs]) -> call_to_scode(Env, aeb_fate_ops:create(?a, ?a, ?a), diff --git a/test/aeso_compiler_tests.erl b/test/aeso_compiler_tests.erl index 2691b03..d51be87 100644 --- a/test/aeso_compiler_tests.erl +++ b/test/aeso_compiler_tests.erl @@ -26,14 +26,14 @@ run_test(Test) -> simple_compile_test_() -> [ {"Testing the " ++ ContractName ++ " contract with the " ++ atom_to_list(Backend) ++ " backend", fun() -> - case compile(Backend, ContractName) of + case compile(Backend, ContractName, [pp_assembler]) of #{byte_code := ByteCode, contract_source := _, type_info := _} when Backend == aevm -> ?assertMatch(Code when is_binary(Code), ByteCode); #{fate_code := Code} when Backend == fate -> Code1 = aeb_fate_code:deserialize(aeb_fate_code:serialize(Code)), - ?assertMatch({X, X}, {Code1, Code}); + ?assertMatch({X, X}, {Code1, Code}), error(xd); ErrBin -> io:format("\n~s", [ErrBin]), error(ErrBin)