Skip to content

Commit 41fa7f9

Browse files
committed
fixup! Try defining subtype(union(), union()) with type_diff()
1 parent 23a1dee commit 41fa7f9

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

src/typechecker.erl

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -366,16 +366,10 @@ compat_ty({type, _, union, _} = U1, {type, _, union, _} = U2, Seen, Env) ->
366366
?type(none) -> ret(Seen);
367367
false -> throw(nomatch)
368368
end;
369-
370-
%compat_ty({type, _, union, Tys1}, {type, _, union, Tys2}, Seen, Env) ->
371-
% lists:foldl(fun (Ty1, {Seen1, C1}) ->
372-
% {Seen2, C2} = any_type(Ty1, Tys2, Seen1, Env),
373-
% {Seen2, constraints:combine(C1, C2, Env)}
374-
% end, {Seen, constraints:empty()}, Tys1);
375-
%compat_ty(Ty1, {type, _, union, Tys2}, Seen, Env) ->
376-
% any_type(Ty1, Tys2, Seen, Env);
377-
%compat_ty({type, _, union, Tys1}, Ty2, Seen, Env) ->
378-
% all_type(Tys1, Ty2, Seen, Env);
369+
compat_ty(Ty1, {type, _, union, Tys2}, Seen, Env) ->
370+
any_type(Ty1, Tys2, Seen, Env);
371+
compat_ty({type, _, union, Tys1}, Ty2, Seen, Env) ->
372+
all_type(Tys1, Ty2, Seen, Env);
379373

380374
% Integer types
381375
compat_ty(Ty1, Ty2, Seen, _Env) when ?is_int_type(Ty1), ?is_int_type(Ty2) ->
@@ -614,16 +608,16 @@ any_type(Ty1, Tys, Seen0, Env) ->
614608
%% @doc All types in `Tys' must be compatible with `Ty'.
615609
%% Returns all the gather memoizations and constraints.
616610
%% Does not return (throws `nomatch') if any of the types is not compatible.
617-
%-spec all_type([type()], type(), map(), env()) -> compat_acc().
618-
%all_type(Tys, Ty, Seen, Env) ->
619-
% all_type(Tys, Ty, Seen, [], Env).
620-
621-
%-spec all_type([type()], type(), map(), [constraints:t()], env()) -> compat_acc().
622-
%all_type([], _Ty, Seen, Css, Env) ->
623-
% {Seen, constraints:combine(Css, Env)};
624-
%all_type([Ty1|Tys], Ty, AIn, Css, Env) ->
625-
% {AOut, Cs} = compat(Ty1, Ty, AIn, Env),
626-
% all_type(Tys, Ty, AOut, [Cs|Css], Env).
611+
-spec all_type([type()], type(), map(), env()) -> compat_acc().
612+
all_type(Tys, Ty, Seen, Env) ->
613+
all_type(Tys, Ty, Seen, [], Env).
614+
615+
-spec all_type([type()], type(), map(), [constraints:t()], env()) -> compat_acc().
616+
all_type([], _Ty, Seen, Css, Env) ->
617+
{Seen, constraints:combine(Css, Env)};
618+
all_type([Ty1|Tys], Ty, AIn, Css, Env) ->
619+
{AOut, Cs} = compat(Ty1, Ty, AIn, Env),
620+
all_type(Tys, Ty, AOut, [Cs|Css], Env).
627621

628622
%% Looks up the fields of a record by name and, if present, by the module where
629623
%% it belongs if a filename is included in the Anno.

0 commit comments

Comments
 (0)