Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
erszcz committed Jun 2, 2024
1 parent cd9603f commit 4f1468f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/typechecker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,22 @@ compat_ty({type, _, 'fun', [{type, _, product, Args1}, Res1]},
{Aps, constraints:combine(Cs, Css, Env)};

%% Unions
compat_ty({type, _, union, _} = U1, {type, _, union, _} = U2, Seen, Env) ->
case type_diff(U1, U2, Env) of
?type(none) -> ret(Seen);
_ -> throw(nomatch)
compat_ty({type, _, union, Tys1} = U1, {type, _, union, Tys2} = U2, Seen, Env) ->
IsAny = fun
(?type(any)) -> true;
(_) -> false
end,
case lists:any(IsAny, Tys1) of
true -> ret(Seen);
false ->
case lists:any(IsAny, Tys2) of
true -> ret(Seen);
false ->
case type_diff(U1, U2, Env) of
?type(none) -> ret(Seen);
_ -> throw(nomatch)
end
end
end;
compat_ty(Ty1, {type, _, union, Tys2}, Seen, Env) ->
any_type(Ty1, Tys2, Seen, Env);
Expand Down

0 comments on commit 4f1468f

Please sign in to comment.