aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-01-27 06:49:52 +0100
committerBjörn Gustavsson <[email protected]>2015-01-28 09:48:39 +0100
commit11dcd4774a6beb28306b9e6e1b80b00d9596bf5f (patch)
tree3efd898883f790989528492916c4976bb266ecdb
parent81d728c44774a4e0367b30d377ac9f136ecf853e (diff)
downloadotp-11dcd4774a6beb28306b9e6e1b80b00d9596bf5f.tar.gz
otp-11dcd4774a6beb28306b9e6e1b80b00d9596bf5f.tar.bz2
otp-11dcd4774a6beb28306b9e6e1b80b00d9596bf5f.zip
sys_core_fold: Remove uncovered clauses matching #c_map{}
sys_core_fold:eval_element/3 attempts to evaluate calls to element/2 at compile time or to warn when the call will obviously fail. For example: element(1, [a]) will obviously fail and eval_element/3 will produce a warning. eval_element/3 uses the helper functions is_not_integer/1 and is_not_tuple/1 to test whether the arguments are known to be incorrect. The clauses that attempt to match #c_map{} in those helper function will never be executed, because #c_map{} will never occur directly in an argument for a function call. For example, code such as: element(1, #{a=>Val}) will be translated to: let <NewVar> = #{a=>Val} in element(1, NewVar) since maps are not considered safe (some map operations may cause an exception at run time).
-rw-r--r--lib/compiler/src/sys_core_fold.erl2
1 files changed, 0 insertions, 2 deletions
diff --git a/lib/compiler/src/sys_core_fold.erl b/lib/compiler/src/sys_core_fold.erl
index 09716d0866..f3e90f8eb2 100644
--- a/lib/compiler/src/sys_core_fold.erl
+++ b/lib/compiler/src/sys_core_fold.erl
@@ -1378,7 +1378,6 @@ eval_is_record(Call, _, _, _, _) -> Call.
is_not_integer(#c_literal{val=Val}) when not is_integer(Val) -> true;
is_not_integer(#c_tuple{}) -> true;
is_not_integer(#c_cons{}) -> true;
-is_not_integer(#c_map{}) -> true;
is_not_integer(_) -> false.
%% is_not_tuple(Core) -> true | false.
@@ -1386,7 +1385,6 @@ is_not_integer(_) -> false.
is_not_tuple(#c_literal{val=Val}) when not is_tuple(Val) -> true;
is_not_tuple(#c_cons{}) -> true;
-is_not_tuple(#c_map{}) -> true;
is_not_tuple(_) -> false.
%% eval_setelement(Call, Pos, Tuple, NewVal) -> Core.