Ban the unification of uvar and var_args function
This commit is contained in:
parent
4ca90feea0
commit
d36642cbc1
@ -2856,6 +2856,8 @@ unify0(Env, A, B, Variance, When) ->
|
|||||||
|
|
||||||
unify1(_Env, {uvar, _, R}, {uvar, _, R}, _Variance, _When) ->
|
unify1(_Env, {uvar, _, R}, {uvar, _, R}, _Variance, _When) ->
|
||||||
true;
|
true;
|
||||||
|
unify1(_Env, {uvar, _, _}, {fun_t, _, _, var_args, _}, _Variance, When) ->
|
||||||
|
type_error({unify_varargs, When});
|
||||||
unify1(Env, {uvar, A, R}, T, _Variance, When) ->
|
unify1(Env, {uvar, A, R}, T, _Variance, When) ->
|
||||||
case occurs_check(R, T) of
|
case occurs_check(R, T) of
|
||||||
true ->
|
true ->
|
||||||
|
@ -261,6 +261,8 @@ type(Type, Options) ->
|
|||||||
with_options(Options, fun() -> type(Type) end).
|
with_options(Options, fun() -> type(Type) end).
|
||||||
|
|
||||||
-spec type(aeso_syntax:type()) -> doc().
|
-spec type(aeso_syntax:type()) -> doc().
|
||||||
|
type(F = {fun_t, _, _, var_args, _}) ->
|
||||||
|
type(setelement(4, F, [var_args]));
|
||||||
type({fun_t, _, Named, Args, Ret}) ->
|
type({fun_t, _, Named, Args, Ret}) ->
|
||||||
follow(hsep(args_type(Named ++ Args), text("=>")), type(Ret));
|
follow(hsep(args_type(Named ++ Args), text("=>")), type(Ret));
|
||||||
type({type_sig, _, Named, Args, Ret}) ->
|
type({type_sig, _, Named, Args, Ret}) ->
|
||||||
@ -288,7 +290,9 @@ type(T = {id, _, _}) -> name(T);
|
|||||||
type(T = {qid, _, _}) -> name(T);
|
type(T = {qid, _, _}) -> name(T);
|
||||||
type(T = {con, _, _}) -> name(T);
|
type(T = {con, _, _}) -> name(T);
|
||||||
type(T = {qcon, _, _}) -> name(T);
|
type(T = {qcon, _, _}) -> name(T);
|
||||||
type(T = {tvar, _, _}) -> name(T).
|
type(T = {tvar, _, _}) -> name(T);
|
||||||
|
|
||||||
|
type(var_args) -> text("var_args").
|
||||||
|
|
||||||
-spec args_type([aeso_syntax:type()]) -> doc().
|
-spec args_type([aeso_syntax:type()]) -> doc().
|
||||||
args_type(Args) ->
|
args_type(Args) ->
|
||||||
|
@ -1139,6 +1139,19 @@ failing_contracts() ->
|
|||||||
" `oracle(string, (int) => int)`\n"
|
" `oracle(string, (int) => int)`\n"
|
||||||
"The response type must not be higher-order (contain function types)">>
|
"The response type must not be higher-order (contain function types)">>
|
||||||
])
|
])
|
||||||
|
, ?TYPE_ERROR(var_args_unify_let,
|
||||||
|
[<<?Pos(3,9)
|
||||||
|
"Cannot unify variable argument list.\n"
|
||||||
|
"when checking the type of the pattern `x : 'a` against the expected type `(gas : int, value : int, protected : bool, ref : 'b, var_args) => 'b`">>
|
||||||
|
])
|
||||||
|
, ?TYPE_ERROR(var_args_unify_fun_call,
|
||||||
|
[<<?Pos(6,5)
|
||||||
|
"Cannot unify variable argument list.\n"
|
||||||
|
"when checking the application of\n"
|
||||||
|
" `g : (() => 'a) => 'a`\n"
|
||||||
|
"to arguments\n"
|
||||||
|
" `Chain.create : (value : int, var_args) => 'b`">>
|
||||||
|
])
|
||||||
].
|
].
|
||||||
|
|
||||||
validation_test_() ->
|
validation_test_() ->
|
||||||
|
7
test/contracts/var_args_unify_fun_call.aes
Normal file
7
test/contracts/var_args_unify_fun_call.aes
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
contract C =
|
||||||
|
stateful function g(h) =
|
||||||
|
h()
|
||||||
|
|
||||||
|
stateful entrypoint f() =
|
||||||
|
g(Chain.create)
|
||||||
|
123
|
4
test/contracts/var_args_unify_let.aes
Normal file
4
test/contracts/var_args_unify_let.aes
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
main contract C =
|
||||||
|
stateful entrypoint f() =
|
||||||
|
let x = Chain.clone
|
||||||
|
123
|
Loading…
x
Reference in New Issue
Block a user