Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
8101-sys_core_fold-Emit-eval_failure-result_ign...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 8101-sys_core_fold-Emit-eval_failure-result_ignored-M-F-A.patch of Package erlang
From 781426e2fb12cc385874c43f9c5ce6dbee2533ef Mon Sep 17 00:00:00 2001 From: Wojtek Mach <wojtek@wojtekmach.pl> Date: Tue, 9 Feb 2021 09:05:52 +0100 Subject: [PATCH] sys_core_fold: Emit {eval_failure|result_ignored, {M, F, A}} --- lib/compiler/src/sys_core_fold.erl | 80 +++++++++++++--------------- lib/compiler/test/warnings_SUITE.erl | 22 ++++---- 2 files changed, 47 insertions(+), 55 deletions(-) diff --git a/lib/compiler/src/sys_core_fold.erl b/lib/compiler/src/sys_core_fold.erl index c1d4323815..71f8f88b0b 100644 --- a/lib/compiler/src/sys_core_fold.erl +++ b/lib/compiler/src/sys_core_fold.erl @@ -2837,31 +2837,7 @@ classify_call(Call) -> Mod = cerl:concrete(cerl:call_module(Call)), Name = cerl:concrete(cerl:call_name(Call)), Arity = cerl:call_arity(Call), - case is_operator(Mod, Name, Arity) of - true -> - {operator,{Name,Arity}}; - false -> - case is_auto_imported(Mod, Name, Arity) of - true -> - {function,{Name,Arity}}; - false -> - {function,{Mod,Name,Arity}} - end - end. - -is_operator(erlang, Name, Arity) -> - try - _ = erl_internal:op_type(Name, Arity), - true - catch - error:_ -> - false - end; -is_operator(_, _, _) -> false. - -is_auto_imported(erlang, Name, Arity) -> - erl_internal:bif(Name, Arity); -is_auto_imported(_, _, _) -> false. + {Mod, Name, Arity}. -type error() :: atom() | tuple(). @@ -2946,26 +2922,42 @@ format_error(invalid_call) -> format_error(useless_building) -> "a term is constructed, but never used". -format_call({function,{erlang,make_fun,3}}, _) -> +format_call({erlang,make_fun,3}, _) -> "fun construction"; -format_call({function,Call}, UseProgressiveForm) -> - [case UseProgressiveForm of - true -> "calling"; - false -> "the call to" - end, - $\s, - case Call of - {M,F,A} -> - io_lib:format("~p:~p/~p", [M,F,A]); - {F,A} -> - io_lib:format("~p/~p", [F,A]) - end]; -format_call({operator,{F,A}}, UseProgressiveForm) -> - Eval = case UseProgressiveForm of - true -> "evaluating"; - false -> "evaluation of" - end, - io_lib:format(Eval ++ " operator ~p/~p", [F,A]). +format_call({Mod, Name, Arity}, UseProgressiveForm) -> + case is_operator(Mod, Name, Arity) of + true -> + Str = case UseProgressiveForm of + true -> "evaluating"; + false -> "evaluation of" + end, + [Str, io_lib:format(" operator ~p/~p", [Name,Arity])]; + false -> + Str = case UseProgressiveForm of + true -> "calling"; + false -> "the call to" + end, + case is_auto_imported(Mod, Name, Arity) of + true -> + [Str, io_lib:format(" ~p/~p", [Name,Arity])]; + false -> + [Str, io_lib:format(" ~p:~p/~p", [Mod,Name,Arity])] + end + end. + +is_operator(erlang, Name, Arity) -> + try + _ = erl_internal:op_type(Name, Arity), + true + catch + error:_ -> + false + end; +is_operator(_, _, _) -> false. + +is_auto_imported(erlang, Name, Arity) -> + erl_internal:bif(Name, Arity); +is_auto_imported(_, _, _) -> false. -ifdef(DEBUG). %% In order for simplify_let/2 to work correctly, the list of diff --git a/lib/compiler/test/warnings_SUITE.erl b/lib/compiler/test/warnings_SUITE.erl index 51c023ddba..05e5278602 100644 --- a/lib/compiler/test/warnings_SUITE.erl +++ b/lib/compiler/test/warnings_SUITE.erl @@ -237,12 +237,12 @@ guard(Config) when is_list(Config) -> {warnings, [{2,sys_core_fold,no_clause_match}, {2,sys_core_fold,nomatch_guard}, - {2,sys_core_fold,{eval_failure, {function,{element,2}}, badarg}}, + {2,sys_core_fold,{eval_failure, {erlang,element,2}, badarg}}, {4,sys_core_fold,no_clause_match}, {4,sys_core_fold,nomatch_guard}, {6,sys_core_fold,no_clause_match}, {6,sys_core_fold,nomatch_guard}, - {6,sys_core_fold,{eval_failure, {function,{element,2}}, badarg}} + {6,sys_core_fold,{eval_failure, {erlang,element,2}, badarg}} ]}}], [] = run(Config, Ts), @@ -269,13 +269,13 @@ bad_arith(Config) when is_list(Config) - [], {warnings, [{3,sys_core_fold,nomatch_guard}, - {3,sys_core_fold,{eval_failure, {operator,{'+',2}}, badarith}}, + {3,sys_core_fold,{eval_failure, {erlang,'+',2}, badarith}}, {9,sys_core_fold,nomatch_guard}, - {9,sys_core_fold,{eval_failure, {operator,{'+',2}}, badarith}}, + {9,sys_core_fold,{eval_failure, {erlang,'+',2}, badarith}}, {9,sys_core_fold,{no_effect,{erlang,is_integer,1}}}, {10,sys_core_fold,nomatch_guard}, - {10,sys_core_fold,{eval_failure, {operator,{'+',2}}, badarith}}, - {15,sys_core_fold,{eval_failure, {operator,{'+',2}}, badarith}} + {10,sys_core_fold,{eval_failure, {erlang,'+',2}, badarith}}, + {15,sys_core_fold,{eval_failure, {erlang,'+',2}, badarith}} ] }}], [] = run(Config, Ts), ok. @@ -353,8 +353,8 @@ files(Config) when is_list(Config) -> ">>, [], {warnings, - [{"file1",[{17,sys_core_fold,{eval_failure, {operator,{'/',2}}, badarith}}]}, - {"file2",[{10,sys_core_fold,{eval_failure, {operator,{'/',2}}, badarith}}]}]}}], + [{"file1",[{17,sys_core_fold,{eval_failure, {erlang,'/',2}, badarith}}]}, + {"file2",[{10,sys_core_fold,{eval_failure, {erlang,'/',2}, badarith}}]}]}}], [] = run(Config, Ts), ok. @@ -484,12 +484,12 @@ effect(Config) when is_list(Config) -> [], {warnings,[{5,sys_core_fold,{no_effect,{erlang,is_integer,1}}}, {7,sys_core_fold,useless_building}, - {9,sys_core_fold,{result_ignored,{function,{abs,1}}}}, + {9,sys_core_fold,{result_ignored,{erlang,abs,1}}}, {9,sys_core_fold,useless_building}, {13,sys_core_fold,useless_building}, {15,sys_core_fold,useless_building}, {17,sys_core_fold,useless_building}, - {19,sys_core_fold,{result_ignored,{operator,{'*',2}}}}]}}, + {19,sys_core_fold,{result_ignored,{erlang,'*',2}}}]}}, {21,sys_core_fold,useless_building}, {21,sys_core_fold,{no_effect,{erlang,date,0}}}, {21,sys_core_fold,{no_effect,{erlang,node,0}}}, @@ -844,7 +844,7 @@ underscore(Config) when is_list(Config) {3,sys_core_fold,useless_building}, {4,sys_core_fold,useless_building}, {7,sys_core_fold,result_ignored}, - {8,sys_core_fold,{result_ignored,{operator,{'/',2}}}}, + {8,sys_core_fold,{result_ignored,{erlang,'/',2}}}, {11,sys_core_fold,useless_building}, {14,sys_core_fold,useless_building}], -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor