Fix dependent type in CLONE
This commit is contained in:
parent
851952987c
commit
545f16da65
@ -454,6 +454,7 @@ global_env() ->
|
|||||||
{"require", Fun([Bool, String], Unit)}])
|
{"require", Fun([Bool, String], Unit)}])
|
||||||
, types = MkDefs(
|
, types = MkDefs(
|
||||||
[{"int", 0}, {"bool", 0}, {"char", 0}, {"string", 0}, {"address", 0},
|
[{"int", 0}, {"bool", 0}, {"char", 0}, {"string", 0}, {"address", 0},
|
||||||
|
{"void", 0},
|
||||||
{"unit", {[], {alias_t, Unit}}},
|
{"unit", {[], {alias_t, Unit}}},
|
||||||
{"hash", {[], {alias_t, Bytes(32)}}},
|
{"hash", {[], {alias_t, Bytes(32)}}},
|
||||||
{"signature", {[], {alias_t, Bytes(64)}}},
|
{"signature", {[], {alias_t, Bytes(64)}}},
|
||||||
@ -476,14 +477,14 @@ global_env() ->
|
|||||||
{"gas_limit", Int},
|
{"gas_limit", Int},
|
||||||
{"bytecode_hash",Fun1(Address, Option(Hash))},
|
{"bytecode_hash",Fun1(Address, Option(Hash))},
|
||||||
{"create", FunCN(create,
|
{"create", FunCN(create,
|
||||||
[ {named_arg_t, Ann, {id, Ann, "value"}, Int, {int, Ann, 0}}
|
[ {named_arg_t, Ann, {id, Ann, "value"}, Int, {typed, Ann, {int, Ann, 0}, Int}}
|
||||||
, {named_arg_t, Ann, {id, Ann, "code"}, A, undefined}
|
, {named_arg_t, Ann, {id, Ann, "code"}, A, undefined}
|
||||||
], var_args, A)},
|
], var_args, A)},
|
||||||
{"clone", FunCN(clone,
|
{"clone", FunCN(clone,
|
||||||
[ {named_arg_t, Ann, {id, Ann, "gas"}, Int,
|
[ {named_arg_t, Ann, {id, Ann, "gas"}, Int,
|
||||||
{qid, Ann, ["Call","gas_left"]}}
|
{qid, Ann, ["Call","gas_left"]}}
|
||||||
, {named_arg_t, Ann, {id, Ann, "value"}, Int, {int, Ann, 0}}
|
, {named_arg_t, Ann, {id, Ann, "value"}, Int, {typed, Ann, {int, Ann, 0}, Int}}
|
||||||
, {named_arg_t, Ann, {id, Ann, "protected"}, Bool, {bool, Ann, false}}
|
, {named_arg_t, Ann, {id, Ann, "protected"}, Bool, {typed, Ann, {bool, Ann, false}, Bool}}
|
||||||
, {named_arg_t, Ann, {id, Ann, "ref"}, A, undefined}
|
, {named_arg_t, Ann, {id, Ann, "ref"}, A, undefined}
|
||||||
], var_args, A)},
|
], var_args, A)},
|
||||||
%% Tx constructors
|
%% Tx constructors
|
||||||
@ -1484,9 +1485,10 @@ infer_expr(Env, {app, Ann, Fun, Args0} = App) ->
|
|||||||
lists:filter(fun({named_arg_t, _, {id, _, "ref"}, _, _}) -> false; (_) -> true end, NamedArgsT),
|
lists:filter(fun({named_arg_t, _, {id, _, "ref"}, _, _}) -> false; (_) -> true end, NamedArgsT),
|
||||||
{typed, _, _, InitT} =
|
{typed, _, _, InitT} =
|
||||||
infer_expr(Env, {proj, CAnn, Contract, {id, [], "init"}}),
|
infer_expr(Env, {proj, CAnn, Contract, {id, [], "init"}}),
|
||||||
unify(Env, InitT, {fun_t, FunAnn, NamedArgsTNoRef, ArgTypes, fresh_uvar(CAnn)}, checking_init_todo),
|
unify(Env, InitT, {fun_t, FunAnn, NamedArgsTNoRef, ArgTypes, fresh_uvar(Ann)}, checking_init_todo),
|
||||||
unify(Env, RetT, ContractT, dupadupa_todo),
|
unify(Env, RetT, ContractT, dupadupa_todo),
|
||||||
{fun_t, FunAnn, NamedArgsT, ArgTypes, RetT};
|
{fun_t, Ann, NamedArgsT, ArgTypes,
|
||||||
|
{if_t, Ann, {id, Ann, "protected"}, {app_t, Ann, {id, Ann, "option"}, [RetT]}, RetT}};
|
||||||
_ -> FunType0
|
_ -> FunType0
|
||||||
end,
|
end,
|
||||||
GeneralResultType = fresh_uvar(Ann),
|
GeneralResultType = fresh_uvar(Ann),
|
||||||
@ -1907,6 +1909,7 @@ check_named_argument_constraint(Env,
|
|||||||
general_type = GenType,
|
general_type = GenType,
|
||||||
specialized_type = SpecType,
|
specialized_type = SpecType,
|
||||||
context = {check_return, App} }) ->
|
context = {check_return, App} }) ->
|
||||||
|
io:format("CEHCK DEP: GEN ~p, SPEC: ~p\n", [GenType, SpecType]),
|
||||||
NamedArgsT = dereference(NamedArgsT0),
|
NamedArgsT = dereference(NamedArgsT0),
|
||||||
case dereference(NamedArgsT0) of
|
case dereference(NamedArgsT0) of
|
||||||
[_ | _] = NamedArgsT ->
|
[_ | _] = NamedArgsT ->
|
||||||
@ -1931,6 +1934,7 @@ specialize_dependent_type(Env, Type) ->
|
|||||||
{typed, _, {bool, _, false}, _} -> Else;
|
{typed, _, {bool, _, false}, _} -> Else;
|
||||||
_ ->
|
_ ->
|
||||||
type_error({named_argument_must_be_literal_bool, Arg, Val}),
|
type_error({named_argument_must_be_literal_bool, Arg, Val}),
|
||||||
|
io:format("CHYUJ: ~p\n", [Val]),
|
||||||
fresh_uvar(aeso_syntax:get_ann(Val))
|
fresh_uvar(aeso_syntax:get_ann(Val))
|
||||||
end;
|
end;
|
||||||
_ -> Type %% Currently no deep dependent types
|
_ -> Type %% Currently no deep dependent types
|
||||||
@ -2457,8 +2461,6 @@ occurs_check1(R, [H | T]) ->
|
|||||||
occurs_check(R, H) orelse occurs_check(R, T);
|
occurs_check(R, H) orelse occurs_check(R, T);
|
||||||
occurs_check1(_, []) -> false.
|
occurs_check1(_, []) -> false.
|
||||||
|
|
||||||
fresh_uvar([{origin, system}]) ->
|
|
||||||
error(oh_no_you_dont);
|
|
||||||
fresh_uvar(Attrs) ->
|
fresh_uvar(Attrs) ->
|
||||||
{uvar, Attrs, make_ref()}.
|
{uvar, Attrs, make_ref()}.
|
||||||
|
|
||||||
|
@ -475,6 +475,8 @@ type_to_fcode(Env, Sub, {record_t, Fields}) ->
|
|||||||
type_to_fcode(Env, Sub, {tuple_t, [], lists:map(FieldType, Fields)});
|
type_to_fcode(Env, Sub, {tuple_t, [], lists:map(FieldType, Fields)});
|
||||||
type_to_fcode(_Env, _Sub, {bytes_t, _, N}) ->
|
type_to_fcode(_Env, _Sub, {bytes_t, _, N}) ->
|
||||||
{bytes, N};
|
{bytes, N};
|
||||||
|
type_to_fcode(_Env, _Sub, {tvar, Ann, "void"}) ->
|
||||||
|
fcode_error({found_void, Ann});
|
||||||
type_to_fcode(_Env, Sub, {tvar, _, X}) ->
|
type_to_fcode(_Env, Sub, {tvar, _, X}) ->
|
||||||
maps:get(X, Sub, {tvar, X});
|
maps:get(X, Sub, {tvar, X});
|
||||||
type_to_fcode(_Env, _Sub, {fun_t, Ann, _, var_args, _}) ->
|
type_to_fcode(_Env, _Sub, {fun_t, Ann, _, var_args, _}) ->
|
||||||
|
@ -91,6 +91,8 @@ format({var_args_not_set, Expr}) ->
|
|||||||
mk_err( pos(Expr), "Could not deduce type of variadic arguments"
|
mk_err( pos(Expr), "Could not deduce type of variadic arguments"
|
||||||
, "When compiling " ++ pp_expr(Expr)
|
, "When compiling " ++ pp_expr(Expr)
|
||||||
);
|
);
|
||||||
|
format({found_void, Ann}) ->
|
||||||
|
mk_err(pos(Ann), "Found a void-typed value.", "`void` is a restricted, uninhabited type. Did you mean `unit`?");
|
||||||
|
|
||||||
format(Err) ->
|
format(Err) ->
|
||||||
mk_err(aeso_errors:pos(0, 0), io_lib:format("Unknown error: ~p\n", [Err])).
|
mk_err(aeso_errors:pos(0, 0), io_lib:format("Unknown error: ~p\n", [Err])).
|
||||||
|
@ -182,7 +182,7 @@ compilable_contracts() ->
|
|||||||
"protected_call",
|
"protected_call",
|
||||||
"hermetization_turnoff",
|
"hermetization_turnoff",
|
||||||
"multiple_contracts",
|
"multiple_contracts",
|
||||||
"clone"
|
"clone", "clone_simple"
|
||||||
].
|
].
|
||||||
|
|
||||||
not_compilable_on(fate) -> [];
|
not_compilable_on(fate) -> [];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user