From 2ed9b1102a18ec62bb4b1dfbb2dc0b4c0c159611 Mon Sep 17 00:00:00 2001 From: Gaith Hallak Date: Fri, 10 Dec 2021 14:40:42 +0200 Subject: [PATCH] Fix dialyzer warnings --- src/aeso_ast_infer_types.erl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index 0f1935d..ce6cdad 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -84,6 +84,11 @@ -type field_constraint() :: #field_constraint{} | #record_create_constraint{} | #is_contract_constraint{}. +-type byte_constraint() :: {is_bytes, utype()} + | {add_bytes, aeso_syntax:ann(), concat | split, utype(), utype(), utype()}. + +-type constraint() :: named_argument_constraint() | field_constraint() | byte_constraint(). + -record(field_info, { ann :: aeso_syntax:ann() , field_t :: utype() @@ -2074,7 +2079,7 @@ when_option(Opt, Do) -> create_constraints() -> ets_new(constraints, [ordered_set]). --spec add_constraint(byte_constraint() | named_argument_constraint() | field_constraint()) -> true. +-spec add_constraint(constraint() | [constraint()]) -> true. add_constraint(Constraint) -> ets_insert_ordered(constraints, Constraint). @@ -2113,9 +2118,11 @@ solve_constraints(Env) -> (_) -> true end, AmbiguousConstraints = lists:filter(IsAmbiguous, get_constraints()), + + % The two passes on AmbiguousConstraints are needed solve_ambiguous_constraints(Env, AmbiguousConstraints ++ AmbiguousConstraints). --spec solve_ambiguous_constraints(env(), [field_constraint() | named_argument_constraint() | byte_constraint()]) -> ok. +-spec solve_ambiguous_constraints(env(), [constraint()]) -> ok. solve_ambiguous_constraints(Env, Constraints) -> Unknown = solve_known_record_types(Env, Constraints), if Unknown == [] -> ok; @@ -2228,9 +2235,6 @@ specialize_dependent_type(Env, Type) -> %% -- Bytes constraints -- --type byte_constraint() :: {is_bytes, utype()} - | {add_bytes, aeso_syntax:ann(), concat | split, utype(), utype(), utype()}. - solve_constraint(_Env, #field_constraint{record_t = {uvar, _, _}}) -> not_solved; solve_constraint(Env, C = #field_constraint{record_t = RecType, @@ -2358,7 +2362,7 @@ solve_unknown_record_types(Env, Unknown) -> false -> Solutions end. --spec solve_known_record_types(env(), [field_constraint() | named_argument_constraint() | byte_constraint()]) -> [field_constraint()]. +-spec solve_known_record_types(env(), [constraint()]) -> [field_constraint()]. solve_known_record_types(Env, Constraints) -> DerefConstraints = lists:map(fun(C = #field_constraint{record_t = RecordType}) -> C#field_constraint{record_t = dereference(RecordType)};