File 0284-dialyzer-Limit-depth-of-types-at-creation-time.patch of Package erlang

From e5be47ecb77b5c69173c812cd2ef625bc3c82870 Mon Sep 17 00:00:00 2001
From: Hans Bolinder <hasse@erlang.org>
Date: Mon, 9 Aug 2021 15:19:05 +0200
Subject: [PATCH 4/7] dialyzer: Limit depth of types at creation time

When translating forms to types, there is no need create types that
are deeper than needed. The maximal depth currently used is 5, in
dialyzer_typesig.
---
 lib/dialyzer/src/erl_types.erl | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/dialyzer/src/erl_types.erl b/lib/dialyzer/src/erl_types.erl
index dd76314cdd..7b88ebd59c 100644
--- a/lib/dialyzer/src/erl_types.erl
+++ b/lib/dialyzer/src/erl_types.erl
@@ -4749,6 +4749,10 @@ initial_typenames({type, MTA, _File}) -> [{type, MTA}];
 initial_typenames({spec, _MFA, _File}) -> [];
 initial_typenames({record, _MRA, _File}) -> [].
 
+%% 4 is the maximal depth used by any Dialyzer module
+%% (5 is used internally).
+-define(TYPE_LIMIT, 4).
+
 from_form_loop(Form, State, D, Limit, C, T0) ->
   {T1, L1, C1} = from_form(Form, State, D, Limit, C),
   Delta = Limit - L1,
@@ -4758,6 +4762,9 @@ from_form_loop(Form, State, D, Limit, C, T0) ->
     Delta * 8 > Limit ->
       %% Save some time by assuming next depth will exceed the limit.
       {T1, C1};
+    D =:= ?TYPE_LIMIT ->
+      %% No need to go deeper than necessary.
+      {T1, C1};
     true ->
       D1 = D + 1,
       from_form_loop(Form, State, D1, Limit, C1, T1)
-- 
2.31.1

openSUSE Build Service is sponsored by