File 0498-Simplify-handling-of-unsafe-funs.patch of Package erlang

From 45b104c49e7ade1a866202f4773094bd90e2e633 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Fri, 11 Oct 2019 14:18:04 +0200
Subject: [PATCH 1/3] Simplify handling of unsafe funs

The `v3_core:safe_fun/3` function was introduced in 1b8ad68361d
to handle unsafe applications of funs (arity mismatches).

119e72d3e76 made all fun variables unsafe. With that change,
the use of `safe_fun/3` can be replaced with `safe/2`.
---
 lib/compiler/src/v3_core.erl | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/lib/compiler/src/v3_core.erl b/lib/compiler/src/v3_core.erl
index 84b5b48df8..2771dea757 100644
--- a/lib/compiler/src/v3_core.erl
+++ b/lib/compiler/src/v3_core.erl
@@ -717,7 +717,7 @@ expr({call,Lc,{atom,Lf,F},As0}, St0) ->
     Op = #c_var{anno=lineno_anno(Lf, St1),name={F,length(As1)}},
     {#iapply{anno=#a{anno=lineno_anno(Lc, St1)},op=Op,args=As1},Aps,St1};
 expr({call,L,FunExp,As0}, St0) ->
-    {Fun,Fps,St1} = safe_fun(length(As0), FunExp, St0),
+    {Fun,Fps,St1} = safe(FunExp, St0),
     {As1,Aps,St2} = safe_list(As0, St1),
     Lanno = lineno_anno(L, St2),
     {#iapply{anno=#a{anno=Lanno},op=Fun,args=As1},Fps ++ Aps,St2};
@@ -1777,15 +1777,6 @@ safe(E0, St0) ->
     {Se,Sps,St2} = force_safe(E1, St1),
     {Se,Eps ++ Sps,St2}.
 
-safe_fun(A0, E0, St0) ->
-    case safe(E0, St0) of
-        {#c_var{name={_,A1}}=E1,Eps,St1} when A1 =/= A0 ->
-            {V,St2} = new_var(St1),
-            {V,Eps ++ [#iset{var=V,arg=E1}],St2};
-        Result ->
-            Result
-    end.
-
 safe_list(Es, St) ->
     foldr(fun (E, {Ces,Esp,St0}) ->
 		  {Ce,Ep,St1} = safe(E, St0),
-- 
2.16.4

openSUSE Build Service is sponsored by