Solve constraints together and in the order they are added #851
@ -2322,8 +2322,7 @@ solve_field_constraints(Env, Constraints) ->
|
|||||||
|
|
||||||
-spec solve_ambiguous_field_constraints(env(), [field_constraint()]) -> ok.
|
-spec solve_ambiguous_field_constraints(env(), [field_constraint()]) -> ok.
|
||||||
solve_ambiguous_field_constraints(Env, Constraints) ->
|
solve_ambiguous_field_constraints(Env, Constraints) ->
|
||||||
NamedArgConstraints = get_named_argument_constraints(),
|
Unknown = solve_known_record_types(Env, Constraints),
|
||||||
Unknown = solve_known_record_types(Env, Constraints, NamedArgConstraints),
|
|
||||||
if Unknown == [] -> ok;
|
if Unknown == [] -> ok;
|
||||||
length(Unknown) < length(Constraints) ->
|
length(Unknown) < length(Constraints) ->
|
||||||
%% progress! Keep trying.
|
%% progress! Keep trying.
|
||||||
@ -2348,23 +2347,10 @@ solve_unknown_record_types(Env, Unknown) ->
|
|||||||
false -> Solutions
|
false -> Solutions
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% Since named argument constraints solving happens after field
|
-spec solve_known_record_types(env(), [field_constraint()]) -> [field_constraint()].
|
||||||
%% constraints solving, try to find if dereferencing a record type
|
solve_known_record_types(Env, Constraints) ->
|
||||||
%% is failing due to unsolved named argument constraint
|
|
||||||
dereference_or_solve_named_argument_constraints(Env, RecType, Cs) ->
|
|
||||||
case dereference(RecType) of
|
|
||||||
UVar = {uvar, _, R} ->
|
|
||||||
L = [DT || DT = #dependent_type_constraint{specialized_type = {uvar, _, STR}} <- Cs, STR == R],
|
|
||||||
solve_named_argument_constraints(Env, L),
|
|
||||||
dereference(UVar);
|
|
||||||
Type ->
|
|
||||||
Type
|
|
||||||
end.
|
|
||||||
|
|
||||||
-spec solve_known_record_types(env(), [field_constraint()], [named_argument_constraint()]) -> [field_constraint()].
|
|
||||||
solve_known_record_types(Env, Constraints, NamedArgConstraints) ->
|
|
||||||
DerefConstraints =
|
DerefConstraints =
|
||||||
[ C#field_constraint{record_t = dereference_or_solve_named_argument_constraints(Env, RecordType, NamedArgConstraints)}
|
[ C#field_constraint{record_t = dereference(RecordType)}
|
||||||
|| C = #field_constraint{record_t = RecordType} <- Constraints ],
|
|| C = #field_constraint{record_t = RecordType} <- Constraints ],
|
||||||
SolvedConstraints =
|
SolvedConstraints =
|
||||||
[begin
|
[begin
|
||||||
@ -2412,7 +2398,7 @@ destroy_and_report_unsolved_field_constraints(Env) ->
|
|||||||
OtherCs),
|
OtherCs),
|
||||||
{ContractCs, []} =
|
{ContractCs, []} =
|
||||||
lists:partition(fun(#is_contract_constraint{}) -> true; (_) -> false end, OtherCs1),
|
lists:partition(fun(#is_contract_constraint{}) -> true; (_) -> false end, OtherCs1),
|
||||||
Unknown = solve_known_record_types(Env, FieldCs, []),
|
Unknown = solve_known_record_types(Env, FieldCs),
|
||||||
if Unknown == [] -> ok;
|
if Unknown == [] -> ok;
|
||||||
true ->
|
true ->
|
||||||
case solve_unknown_record_types(Env, Unknown) of
|
case solve_unknown_record_types(Env, Unknown) of
|
||||||
|
@ -168,7 +168,6 @@ compilable_contracts() ->
|
|||||||
"maps",
|
"maps",
|
||||||
"oracles",
|
"oracles",
|
||||||
"remote_call",
|
"remote_call",
|
||||||
"remote_call_ambiguous_record",
|
|
||||||
"simple",
|
"simple",
|
||||||
"simple_storage",
|
"simple_storage",
|
||||||
"spend_test",
|
"spend_test",
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
contract interface Coin =
|
|
||||||
entrypoint mint : () => int
|
|
||||||
|
|
||||||
contract interface OtherCoin =
|
|
||||||
entrypoint mint : () => int
|
|
||||||
|
|
||||||
main contract Main =
|
|
||||||
function mkCoin() : Coin = ct_11111111111111111111111111111115rHyByZ
|
|
||||||
entrypoint foo() : int =
|
|
||||||
let r = mkCoin()
|
|
||||||
r.mint()
|
|
Loading…
x
Reference in New Issue
Block a user