Skip to content

Commit

Permalink
Eliminate exports from expression arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
richcarl committed Dec 2, 2024
1 parent da363aa commit 40159fe
Show file tree
Hide file tree
Showing 21 changed files with 98 additions and 59 deletions.
3 changes: 2 additions & 1 deletion lib/asn1/src/asn1rtt_jer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ encode_jer({typeinfo,{Module,Type}},Val) ->
encode_jer({sof,Type},Vals) when is_list(Vals) ->
[encode_jer(Type,Val)||Val <- Vals];
encode_jer({choice,Choices},{Alt,Value}) ->
case is_map_key(AltBin = atom_to_binary(Alt,utf8),Choices) of
AltBin = atom_to_binary(Alt,utf8),
case is_map_key(AltBin,Choices) of
true ->
EncodedVal = encode_jer(maps:get(AltBin,Choices),Value),
#{AltBin => EncodedVal};
Expand Down
6 changes: 4 additions & 2 deletions lib/common_test/src/test_server_ctrl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5774,13 +5774,15 @@ write_html_file(File,Content) ->
%% The 'major' log file, which is a pure text file is also written
%% with utf8 encoding
open_utf8_file(File) ->
case file:open(File,AllOpts=[write,{encoding,utf8}]) of
AllOpts = [write,{encoding,utf8}],
case file:open(File,AllOpts) of
{error,Reason} -> {error,{Reason,{File,AllOpts}}};
Result -> Result
end.

open_utf8_file(File,Opts) ->
case file:open(File,AllOpts=[{encoding,utf8}|Opts]) of
AllOpts = [{encoding,utf8}|Opts],
case file:open(File,AllOpts) of
{error,Reason} -> {error,{Reason,{File,AllOpts}}};
Result -> Result
end.
Expand Down
6 changes: 4 additions & 2 deletions lib/dialyzer/src/dialyzer_dataflow.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,8 @@ handle_map(Tree,Map,State) ->
traverse_map_pairs(Pairs, Map1, State1, t_none(), [], []),
InsertPair = fun({KV,assoc,_},Acc) -> erl_types:t_map_put(KV,Acc);
({KV,exact,KVTree},Acc) ->
case t_is_none(T=erl_types:t_map_update(KV,Acc)) of
T = erl_types:t_map_update(KV,Acc),
case t_is_none(T) of
true -> throw({none, Acc, KV, KVTree});
false -> T
end
Expand Down Expand Up @@ -1723,7 +1724,8 @@ bind_guard(Guard, Map, Env, Eval, State0) ->
{{Map1, t_none(), State1}, BE}
end,
Map3 = join_maps_end([BodyMap, HandlerMap], Map1),
case t_is_none(Sup = t_sup(BodyType, HandlerType)) of
Sup = t_sup(BodyType, HandlerType),
case t_is_none(Sup) of
true ->
%% Pick a reason. N.B. We assume that the handler is always
%% compiler-generated if the body is; that way, we won't need to
Expand Down
9 changes: 6 additions & 3 deletions lib/dialyzer/src/dialyzer_typesig.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,8 @@ get_safe_underapprox_1([Pat0|Left], Acc, Map) ->
%% Some assertions in case the syntax gets more premissive in the future
true = #{} =:= cerl:concrete(cerl:map_arg(Pat)),
true = lists:all(fun(P) ->
cerl:is_literal(Op = cerl:map_pair_op(P)) andalso
Op = cerl:map_pair_op(P),
cerl:is_literal(Op) andalso
exact =:= cerl:concrete(Op)
end, cerl:map_es(Pat)),
KeyTrees = lists:map(fun cerl:map_pair_key/1, cerl:map_es(Pat)),
Expand All @@ -1151,7 +1152,8 @@ get_safe_underapprox_1([Pat0|Left], Acc, Map) ->
%% We need to deal with duplicates ourselves
SquashDuplicates =
fun SquashDuplicates([{K,First},{K,Second}|List]) ->
case t_is_none(Inf = t_inf(First, Second)) of
Inf = t_inf(First, Second),
case t_is_none(Inf) of
true -> throw(dont_know);
false -> [{K, Inf}|SquashDuplicates(List)]
end;
Expand Down Expand Up @@ -1179,7 +1181,8 @@ get_safe_overapprox(Pats) ->
lists:map(fun get_safe_overapprox_1/1, Pats).

get_safe_overapprox_1(Pat) ->
case cerl:is_literal(Lit = cerl:fold_literal(Pat)) of
Lit = cerl:fold_literal(Pat),
case cerl:is_literal(Lit) of
true -> t_from_term(cerl:concrete(Lit));
false -> t_any()
end.
Expand Down
6 changes: 3 additions & 3 deletions lib/dialyzer/src/dialyzer_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1107,9 +1107,9 @@ refold_concrete_pat(Val) ->
false -> label(cerl:c_tuple_skel(Els))
end;
[H|T] ->
case cerl:is_literal(HP=refold_concrete_pat(H))
and cerl:is_literal(TP=refold_concrete_pat(T))
of
HP = refold_concrete_pat(H),
TP = refold_concrete_pat(T),
case cerl:is_literal(HP) and cerl:is_literal(TP) of
true -> cerl:abstract(Val);
false -> label(cerl:c_cons_skel(HP, TP))
end;
Expand Down
3 changes: 2 additions & 1 deletion lib/edoc/src/edoc_specs.erl
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@ expand_records(Entries, TypeDefs, DT, Opts, File, Module) ->
{export_type,Ts} <- Module#module.attributes,
is_list(Ts),
{N,I} <- Ts,
ets:member(DT, Name = {#t_name{name = N}, I})],
Name <- [{#t_name{name = N}, I}],
ets:member(DT, Name)],
_ = lists:foreach(fun({N,A}) -> true = seen_type(N, A, P)
end, ExportedTypes),
entries(Entries, P, Opts).
Expand Down
7 changes: 4 additions & 3 deletions lib/et/src/et_wx_viewer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1410,18 +1410,19 @@ create_filter_menu(S=#state{filter_menu = {Menu,Data}}, ActiveFilterName, Filter
Label = lists:concat([pad_string(F#filter.name, 20), "(", N, ")"]),
{N+1, [menuitem(Menu, ?wxID_ANY, Label, {data, F})|Acc]}
end,
D1 = [I1 = wxMenu:append(Menu, ?wxID_ANY, "Same Filter New Scale"),
wxMenu:appendSeparator(Menu)],
I1 = wxMenu:append(Menu, ?wxID_ANY, "Same Filter New Scale"),
D1 = [I1, wxMenu:appendSeparator(Menu)],
wxMenuItem:enable(I1, [{enable,false}]),
{value, Filter} = lists:keysearch(ActiveFilterName, #filter.name, Filters),
Same = lists:concat([pad_string(ActiveFilterName, 20), "(=) same scale"]),
Larger = lists:concat([pad_string(ActiveFilterName, 20), "(+) bigger scale"]),
Smaller = lists:concat([pad_string(ActiveFilterName, 20), "(-) smaller scale"]),
I2 = wxMenu:append(Menu, ?wxID_ANY, "New Filter Same Scale"),
D2 = [menuitem(Menu, ?wxID_ANY, Same, {data, Filter, 0}),
menuitem(Menu, ?wxID_ANY, Smaller, {data, Filter, -1}),
menuitem(Menu, ?wxID_ANY, Larger, {data, Filter, 1}),
wxMenu:appendSeparator(Menu),
I2 = wxMenu:append(Menu, ?wxID_ANY, "New Filter Same Scale"),
I2,
wxMenu:appendSeparator(Menu)],
_ = wxMenuItem:enable(I2, [{enable,false}]),
{_,D3} = lists:foldl(Item, {1,[]}, Filters),
Expand Down
3 changes: 2 additions & 1 deletion lib/kernel/src/application_controller.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,8 @@ handle_info({ac_load_application_reply, AppName, Res}, S) ->

handle_info({ac_start_application_reply, AppName, Res}, S) ->
Start_req = S#state.start_req,
case lists:keyfind(AppName, 1, Starting = S#state.starting) of
Starting = S#state.starting,
case lists:keyfind(AppName, 1, Starting) of
{_AppName, RestartType, Type, From} ->
case Res of
start_it ->
Expand Down
15 changes: 10 additions & 5 deletions lib/kernel/src/dist_ac.erl
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,8 @@ handle_info({ac_application_run, AppName, Res}, S) ->

handle_info({ac_application_not_run, AppName}, S) ->
%% We ordered a stop, and now it has stopped
{value, Appl} = keysearch(AppName, #appl.name, Appls = S#state.appls),
Appls = S#state.appls,
{value, Appl} = keysearch(AppName, #appl.name, Appls),
%% Check if we have somebody waiting for the takeover result;
%% if somebody called stop just before takeover was handled,
NTReqs = del_t_reqs(AppName, S#state.t_reqs, {error, stopped}),
Expand Down Expand Up @@ -470,7 +471,8 @@ handle_info({ac_application_not_run, AppName}, S) ->
handle_info({ac_application_stopped, AppName}, S) ->
%% Somebody called application:stop - reset state as it was before
%% the application was started.
{value, Appl} = keysearch(AppName, #appl.name, Appls = S#state.appls),
Appls = S#state.appls,
{value, Appl} = keysearch(AppName, #appl.name, Appls),
%% Check if we have somebody waiting for the takeover result;
%% if somebody called stop just before takeover was handled,
NTReqs = del_t_reqs(AppName, S#state.t_reqs, {error, stopped}),
Expand Down Expand Up @@ -646,7 +648,8 @@ handle_info({nodedown, Node}, S) ->

handle_info({dist_ac_app_loaded, Node, Name, HisNodes, Permission, HeKnowsMe},
S) ->
Nodes = dist_find_nodes(Appls = S#state.appls, Name),
Appls = S#state.appls,
Nodes = dist_find_nodes(Appls, Name),
case is_loaded(Name, S) of
true ->
case equal_nodes(Nodes, HisNodes) of
Expand Down Expand Up @@ -719,7 +722,8 @@ code_change(_OldVsn, State, _Extra) ->
load(AppName, S) ->
Appls0 = S#state.appls,
%% Get the dist specification for the app on other nodes
DistLoaded = get_dist_loaded(AppName, Load1 = S#state.dist_loaded),
Load1 = S#state.dist_loaded,
DistLoaded = get_dist_loaded(AppName, Load1),
%% Get the local dist specification
Nodes = dist_find_nodes(Appls0, AppName),
FNodes = flat_nodes(Nodes),
Expand Down Expand Up @@ -781,7 +785,8 @@ start_appl(AppName, S, Type) ->
%% Get nodes, and check if App is loaded on all involved nodes.
%% If it is loaded everywhere, we know that we have the same picture
%% of the nodes; otherwise the load wouldn't have succeeded.
Appl = case keysearch(AppName, #appl.name, Appls = S#state.appls) of
Appls = S#state.appls,
Appl = case keysearch(AppName, #appl.name, Appls) of
{value, A} -> A;
_ -> throw({error, {unknown_application, AppName}})
end,
Expand Down
8 changes: 6 additions & 2 deletions lib/mnesia/src/mnesia_recover.erl
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,9 @@ handle_call(Msg, _From, State) ->
{noreply, State}.

do_log_mnesia_up(Node) ->
Yoyo = {mnesia_up, Node, Date = date(), Time = time()},
Date = date(),
Time = time(),
Yoyo = {mnesia_up, Node, Date, Time},
case mnesia_monitor:use_dir() of
true ->
mnesia_log:append(latest_log, Yoyo),
Expand All @@ -778,7 +780,9 @@ do_log_mnesia_up(Node) ->
note_up(Node, Date, Time).

do_log_mnesia_down(Node) ->
Yoyo = {mnesia_down, Node, Date = date(), Time = time()},
Date = date(),
Time = time(),
Yoyo = {mnesia_down, Node, Date, Time},
case mnesia_monitor:use_dir() of
true ->
mnesia_log:append(latest_log, Yoyo),
Expand Down
3 changes: 2 additions & 1 deletion lib/observer/src/crashdump_viewer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,8 @@ do_read_file(File) ->
case check_dump_version(Id) of
{ok,DumpVsn} ->
reset_tables(),
insert_index(Tag,Id,Pos=N1+1),
Pos = N1+1,
insert_index(Tag,Id,Pos),
put_last_tag(Tag,"",Pos),
DecodeOpts = get_decode_opts(DumpVsn),
indexify(Fd,DecodeOpts,Rest,N1),
Expand Down
3 changes: 2 additions & 1 deletion lib/parsetools/src/yecc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2413,7 +2413,8 @@ select_parts(PartDataL) ->
NL = [D#part_data{states = NewS} ||
{W1, #part_data{states = S0}=D} <- Ws,
W1 > 0,
(NewS = ordsets:subtract(S0, S)) =/= []],
NewS <- [ordsets:subtract(S0, S)],
NewS =/= []],
if
length(S) =:= 1; NActions =:= 1 ->
select_parts(NL);
Expand Down
3 changes: 2 additions & 1 deletion lib/snmp/src/agent/snmpa_agent.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2535,7 +2535,8 @@ validate_next_v1_2([], _MibView, Res) ->
%% problems.
%%-----------------------------------------------------------------
mk_next_oid(Vb) ->
case snmpa_mib:lookup(get(mibserver), Oid = Vb#varbind.oid) of
Oid = Vb#varbind.oid,
case snmpa_mib:lookup(get(mibserver), Oid) of
{table_column, _MibEntry, TableEntryOid} ->
[Col | _] = Oid -- TableEntryOid,
Vb#varbind{oid = TableEntryOid ++ [Col+1]};
Expand Down
9 changes: 6 additions & 3 deletions lib/snmp/src/compile/snmpc_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ make_ASN1type({{type,Type},Line}) ->
make_ASN1type({{type_with_size,Type,{range,Lo,Hi}},Line}) ->
case lookup_vartype(Type) of
{value,ASN1type} ->
case allow_size_rfc1902(BaseType = ASN1type#asn1_type.bertype) of
BaseType = ASN1type#asn1_type.bertype,
case allow_size_rfc1902(BaseType) of
true ->
ok;
false ->
Expand Down Expand Up @@ -126,7 +127,8 @@ test_kibbles([], Line) ->
print_error("No kibbles found.",[],Line),
[];
test_kibbles(Kibbles,Line) ->
test_kibbles2(R = lists:keysort(2,Kibbles),0,Line),
R = lists:keysort(2,Kibbles),
test_kibbles2(R,0,Line),
R.

test_kibbles2([],_,_) ->
Expand Down Expand Up @@ -407,7 +409,8 @@ read_mib(_Line, _Filename, []) ->
error;
read_mib(Line, Filename, [Dir|Path]) ->
Dir2 = snmpc_misc:ensure_trailing_dir_delimiter(Dir),
case snmpc_misc:read_mib(AbsFile=lists:append(Dir2, Filename)) of
AbsFile = lists:append(Dir2, Filename),
case snmpc_misc:read_mib(AbsFile) of
{ok, MIB} -> MIB;
{error, enoent} ->
read_mib(Line, Filename, Path);
Expand Down
3 changes: 2 additions & 1 deletion lib/ssh/src/ssh_connection_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,8 @@ handle_event(cast, socket_control, {wait_for_socket, Role},
handle_event(internal, socket_ready, {hello,_}=StateName, #data{ssh_params = Ssh0} = D) ->
VsnMsg = ssh_transport:hello_version_msg(string_version(Ssh0)),
send_bytes(VsnMsg, D),
case inet:getopts(Socket=D#data.socket, [recbuf]) of
Socket = D#data.socket,
case inet:getopts(Socket, [recbuf]) of
{ok, [{recbuf,Size}]} ->
%% Set the socket to the hello text line handling mode:
inet:setopts(Socket, [{packet, line},
Expand Down
2 changes: 1 addition & 1 deletion lib/stdlib/src/edlin_expand.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ match(Prefix, Alts, Extra0) ->
Len = string:length(Prefix),
Matches = lists:sort(
[{S, A} || {H, A} <- Alts2,
lists:prefix(Prefix, S=flat_write(H))]),
S <- [flat_write(H)], lists:prefix(Prefix, S)]),
Matches2 = lists:usort(
case Extra0 of
[] -> [{S,[]} || {S,_} <- Matches];
Expand Down
8 changes: 4 additions & 4 deletions lib/stdlib/src/erl_lint.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3758,8 +3758,8 @@ add_missing_spec_warnings(Forms, St0, Type) ->
Warns = %% functions + line numbers for which we should warn
case Type of
all ->
[{FA,Anno} || {function,Anno,F,A,_} <- Forms,
not lists:member(FA = {F,A}, Specs)];
[{{F,A},Anno} || {function,Anno,F,A,_} <- Forms,
not lists:member({F,A}, Specs)];
_ ->
Exps0 = gb_sets:to_list(exports(St0)) -- pseudolocals(),
Exps1 =
Expand All @@ -3769,8 +3769,8 @@ add_missing_spec_warnings(Forms, St0, Type) ->
Exps0
end,
Exps = Exps1 -- Specs,
[{FA,Anno} || {function,Anno,F,A,_} <- Forms,
member(FA = {F,A}, Exps)]
[{{F,A},Anno} || {function,Anno,F,A,_} <- Forms,
member({F,A}, Exps)]
end,
foldl(fun ({FA,Anno}, St) ->
add_warning(Anno, {missing_spec,FA}, St)
Expand Down
16 changes: 10 additions & 6 deletions lib/stdlib/src/qlc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1275,8 +1275,9 @@ For the various options recognized by `table/1,2` in respective module, see
Args :: [term()],
QH :: query_handle().
table(TraverseFun, Options) when is_function(TraverseFun) ->
case {is_function(TraverseFun, 0),
IsFun1 = is_function(TraverseFun, 1)} of
IsFun0 = is_function(TraverseFun, 0),
IsFun1 = is_function(TraverseFun, 1),
case {IsFun0, IsFun1} of
{false, false} ->
erlang:error(badarg, [TraverseFun, Options]);
_ ->
Expand Down Expand Up @@ -2503,10 +2504,12 @@ qlc_sort_info(Qdata0, QOpt) ->

sort_info(#prepared{sort_info = SI, sorted = S} = Prep, QNum, QOpt) ->
SI1 = [{{C,Ord},[]} ||
S =/= no,
is_integer(Sz = size_of_qualifier(QOpt, QNum)),
S =/= no,
Sz <- [size_of_qualifier(QOpt, QNum)],
is_integer(Sz),
Sz > 0, % the size of the pattern
(NConstCols = size_of_constant_prefix(QOpt, QNum)) < Sz,
NConstCols <- [size_of_constant_prefix(QOpt, QNum)],
NConstCols < Sz,
C <- [NConstCols+1],
Ord <- orders(S)]
++ [{{Pos,Ord},[]} || Pos <- constant_columns(QOpt, QNum),
Expand Down Expand Up @@ -2588,7 +2591,8 @@ pos_vals(_Pos, _KeyEquality, _T, _Max) ->
nub([]) ->
[];
nub([E | L]) ->
case lists:member(E, Es=nub(L)) of
Es=nub(L),
case lists:member(E, Es) of
true ->
Es;
false ->
Expand Down
Loading

0 comments on commit 40159fe

Please sign in to comment.