diff --git a/lib/dialyzer/src/dialyzer_contracts.erl b/lib/dialyzer/src/dialyzer_contracts.erl index 74b7d5876768..1efb6af56681 100644 --- a/lib/dialyzer/src/dialyzer_contracts.erl +++ b/lib/dialyzer/src/dialyzer_contracts.erl @@ -321,8 +321,8 @@ locate_invalid_elems([Contract], SuccType) -> ProblematicArgs = [erl_types:t_is_none(erl_types:t_inf(Cont, Succ)) andalso - (not erl_types:t_is_none(Cont)) - || {Cont, Succ} <- lists:zip(CArgs, SArgs)], + (not erl_types:t_is_none(Cont)) || + Cont <- CArgs && Succ <- SArgs], ProblematicRange = erl_types:t_is_impossible(erl_types:t_inf(CRange, SRange)) diff --git a/lib/dialyzer/src/dialyzer_dataflow.erl b/lib/dialyzer/src/dialyzer_dataflow.erl index aaeaf05a0f1f..59494fa052b4 100644 --- a/lib/dialyzer/src/dialyzer_dataflow.erl +++ b/lib/dialyzer/src/dialyzer_dataflow.erl @@ -354,8 +354,7 @@ handle_apply(Tree, Map, State) -> NewArgs = t_inf_lists(ArgTypes, t_fun_args(OpType1)), case any_none(NewArgs) of true -> - EnumNewArgs = lists:zip(lists:seq(1, length(NewArgs)), - NewArgs), + EnumNewArgs = lists:enumerate(NewArgs), ArgNs = [Arg || {Arg, Type} <- EnumNewArgs, t_is_none(Type)], Msg = {fun_app_args, @@ -545,7 +544,7 @@ handle_apply_or_call([{TypeOfApply, {Fun, Sig, Contr, LocalRet}}|Left], NewAccArgTypes = case FailedConj of true -> AccArgTypes; - false -> [t_sup(X, Y) || {X, Y} <- lists:zip(NewArgTypes, AccArgTypes)] + false -> [t_sup(X, Y) || X <- NewArgTypes && Y <- AccArgTypes] end, TotalRet = case t_is_none(LocalRet) andalso t_is_unit(RetWithoutLocal) of @@ -642,8 +641,8 @@ get_apply_fail_msg(Fun, Args, ArgTypes, NewArgTypes, dialyzer_contracts:contract_to_string(C)}; none -> {false, none} end, - EnumArgTypes = lists:zip(lists:seq(1, length(NewArgTypes)), NewArgTypes), - ArgNs = [Arg || {Arg, Type} <- EnumArgTypes, t_is_none(Type)], + ArgNs = [Arg || Arg <- lists:seq(1, length(NewArgTypes)) && + Type <- NewArgTypes, t_is_none(Type)], case state__lookup_name(Fun, State) of {M, F, _A} -> {call, [M, F, ArgStrings, @@ -1162,7 +1161,7 @@ opaque_clauses(Clauses, ClauseTypes, #state{module=Module}=State) -> [erl_types:t_is_opaque(Type, Module), format_type(Type, State)]}, clause_error_warning(Msg, false, Clause) - end || {Clause, Type} <- lists:zip(Clauses, ClauseTypes), + end || Clause <- Clauses && Type <- ClauseTypes, not erl_types:t_is_impossible(Type), not erl_types:t_is_any(Type)] else @@ -3249,7 +3248,7 @@ forward_args(Fun, ArgTypes, #state{work = Work, fun_tab = FunTab} = State) -> {ArgTypes, OldOut0, false}; {ok, {OldArgTypes0, OldOut0}} -> NewArgTypes0 = [t_sup(X, Y) || - {X, Y} <- lists:zip(ArgTypes, OldArgTypes0)], + X <- ArgTypes && Y <- OldArgTypes0], {NewArgTypes0, OldOut0, t_is_equal(t_product(NewArgTypes0), t_product(OldArgTypes0))} end, diff --git a/lib/dialyzer/src/dialyzer_dep.erl b/lib/dialyzer/src/dialyzer_dep.erl index 16afac00d803..f010617d0c7c 100644 --- a/lib/dialyzer/src/dialyzer_dep.erl +++ b/lib/dialyzer/src/dialyzer_dep.erl @@ -438,7 +438,7 @@ merge_outs([#output{type = single, content = S1}|Left], merge_outs(Left, output(set__union(S1, S2))); merge_outs([#output{type = list, content = L1}|Left], #output{type = list, content = L2}) -> - NewList = [merge_outs([X, Y]) || {X, Y} <- lists:zip(L1, L2)], + NewList = [merge_outs([X, Y]) || X <- L1 && Y <- L2], merge_outs(Left, output(NewList)); merge_outs([], Res) -> Res. diff --git a/lib/dialyzer/src/dialyzer_iplt.erl b/lib/dialyzer/src/dialyzer_iplt.erl index 819592574fae..d3ba62a2a839 100644 --- a/lib/dialyzer/src/dialyzer_iplt.erl +++ b/lib/dialyzer/src/dialyzer_iplt.erl @@ -402,26 +402,18 @@ compute_new_md5_1(Entries, InitDiffs, ModuleToPathLookup) -> ExistingHashes = [Md5 || {_Module, Md5} <- Entries], Files = [maps:get(Module, ModuleToPathLookup) || Module <- Modules], NewHashes = dialyzer_utils:p_map(fun compute_md5_from_file/1, Files), - Diffs = - lists:zipwith3( - fun (Module, BeforeHash, AfterHash) -> - case BeforeHash of - AfterHash -> - none; - _ -> - {differ, Module} - end - end, - Modules, - ExistingHashes, - NewHashes), - Diffs1 = InitDiffs ++ lists:filter(fun ({differ,_}) -> true; (none) -> false end, Diffs), - case Diffs1 of + Diffs = InitDiffs ++ + [{differ, Module} || + Module <- Modules && + BeforeHash <- ExistingHashes && + AfterHash <- NewHashes, + BeforeHash =/= AfterHash], + case Diffs of [] -> ok; _ -> ModuleHashes = lists:zip(Modules, NewHashes), - {differ, lists:keysort(1, ModuleHashes), Diffs1} + {differ, lists:sort(ModuleHashes), Diffs} end. -spec implementation_module_paths() -> module_file_path_lookup(). diff --git a/lib/dialyzer/src/dialyzer_typesig.erl b/lib/dialyzer/src/dialyzer_typesig.erl index da809051b399..482a991bad41 100644 --- a/lib/dialyzer/src/dialyzer_typesig.erl +++ b/lib/dialyzer/src/dialyzer_typesig.erl @@ -818,13 +818,13 @@ get_plt_constr(MFA, Dst, ArgVars, State) -> end, ArgVars), GenArgs}; {value, {PltRetType, PltArgTypes}} -> %% Need to combine the contract with the success typing. - {?mk_fun_var( - fun(Map) -> - ArgTypes = lookup_type_list(ArgVars, Map), + {?mk_fun_var( + fun(Map) -> + ArgTypes = lookup_type_list(ArgVars, Map), CRet = get_contract_return(C, ArgTypes), - t_inf(CRet, PltRetType) - end, ArgVars), - [t_inf(X, Y) || {X, Y} <- lists:zip(GenArgs, PltArgTypes)]} + t_inf(CRet, PltRetType) + end, ArgVars), + [t_inf(X, Y) || X <- GenArgs && Y <- PltArgTypes]} end, state__store_conj_lists([Dst|ArgVars], sub, [RetType|ArgCs], State) end. @@ -2640,8 +2640,7 @@ state__store_funs(Vars0, Funs0, #state{fun_map = Map} = State) -> debug_make_name_map(Vars0, Funs0), Vars = mk_var_list(Vars0), Funs = mk_var_list(Funs0), - NewMap = lists:foldl(fun({Var, Fun}, MP) -> maps:put(Fun, Var, MP) end, - Map, lists:zip(Vars, Funs)), + NewMap = maps:merge(Map, #{Fun => Var || Var <- Vars && Fun <- Funs}), State#state{fun_map = NewMap}. state__get_rec_var(Fun, #state{fun_map = Map}) -> diff --git a/lib/dialyzer/src/erl_types.erl b/lib/dialyzer/src/erl_types.erl index a772b3252020..2588e7aa240d 100644 --- a/lib/dialyzer/src/erl_types.erl +++ b/lib/dialyzer/src/erl_types.erl @@ -2227,10 +2227,8 @@ t_sup_aux(T1, T2) -> -spec t_sup_lists([erl_type()], [erl_type()]) -> [erl_type()]. -t_sup_lists([T1|Left1], [T2|Left2]) -> - [t_sup(T1, T2)|t_sup_lists(Left1, Left2)]; -t_sup_lists([], []) -> - []. +t_sup_lists(Ts1, Ts2) -> + [t_sup(T1, T2) || T1 <- Ts1 && T2 <- Ts2]. %% Adds the new nominal `Sup` into the set of nominals `Ns0`. Note that it does %% not handle structurals; the caller is expected to normalize the result @@ -2715,10 +2713,8 @@ t_inf_aux(#c{}, #c{}) -> -spec t_inf_lists([erl_type()], [erl_type()]) -> [erl_type()]. -t_inf_lists([T1 | Left1], [T2 | Left2]) -> - [t_inf(T1, T2) | t_inf_lists(Left1, Left2)]; -t_inf_lists([], []) -> - []. +t_inf_lists(Ts1, Ts2) -> + [t_inf(T1, T2) || T1 <- Ts1 && T2 <- Ts2]. %% Infimum of lists with strictness. %% If any element is the ?none type, the value 'bottom' is returned. @@ -3344,14 +3340,7 @@ t_subtract_aux(T1, T2) -> -spec t_subtract_lists([erl_type()], [erl_type()]) -> [erl_type()]. t_subtract_lists(L1, L2) -> - t_subtract_lists(L1, L2, []). - --spec t_subtract_lists([erl_type()], [erl_type()], [erl_type()]) -> [erl_type()]. - -t_subtract_lists([T1|Left1], [T2|Left2], Acc) -> - t_subtract_lists(Left1, Left2, [t_subtract(T1, T2)|Acc]); -t_subtract_lists([], [], Acc) -> - lists:reverse(Acc). + [t_subtract(T1, T2) || T1 <- L1 && T2 <- L2]. -spec subtract_union([erl_type(),...], [erl_type(),...]) -> erl_type(). @@ -3398,10 +3387,12 @@ sns_cartesian_1(A, []) -> %% should contain a single element that is not none. That element %% will replace the element in the corresponding position in the %% first list. -replace_nontrivial_element([T1|Left1], [?none|Left2]) -> - [T1|replace_nontrivial_element(Left1, Left2)]; -replace_nontrivial_element([_|Left1], [T2|_]) -> - [T2|Left1]. + +replace_nontrivial_element(Left, Right) -> + [case T2 of + ?none -> T1; + _ -> T2 + end || T1 <- Left && T2 <- Right]. subtract_bin(?bitstr(U1, B1), ?bitstr(U1, B1)) -> ?none;