File 1302-Add-documentation-about-indirect-inherits-option.patch of Package erlang

From c0280a62713ca5009350eaed16bcda6d7fe57876 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20W=C4=85sowski?= <michal@erlang.org>
Date: Thu, 25 Sep 2025 11:29:41 +0200
Subject: [PATCH 2/3] Add documentation about indirect-inherits option

---
 lib/diameter/doc/references/diameter_dict.md | 101 +++++++++++++++++++
 lib/diameter/doc/references/diameterc_cmd.md |  11 +-
 lib/diameter/src/compiler/diameter_make.erl  |  20 ++++
 3 files changed, 128 insertions(+), 4 deletions(-)

diff --git a/lib/diameter/doc/references/diameter_dict.md b/lib/diameter/doc/references/diameter_dict.md
index 2f589acd02..75ab3aeb20 100644
--- a/lib/diameter/doc/references/diameter_dict.md
+++ b/lib/diameter/doc/references/diameter_dict.md
@@ -163,6 +163,57 @@ order in which sections are specified is unimportant.
   @inherits diameter_gen_base_rfc6733
   ```
 
+  When using the `indirect_inherits` option from [codec/2](`diameter_make:codec/2`), 
+  only `@vendor` from the dictionary that defined the AVPs and `@avp_vendor_id`
+  in the currently compiled dictionary is used. All other dictionaries along the
+  chain are ignored, so for example:
+
+  `a.dia`:
+  ```text
+  @vendor 1 A
+  @avp_types
+      AAA 111 Unsigned32 V
+      BBB 222 Unsigned32 V
+  ```
+  `a.dia` will see:
+    - AAA vendor_id = 1
+    - BBB vendor_id = 1
+
+  `b.dia`:
+  ```text
+  @vendor 2 B
+  @avp_types
+      CCC 333 Unsigned32 V
+  @inherits diameter_a
+  @avp_vendor_id 4
+      AAA
+  ```
+
+  `b.dia` will see:
+    - AAA vendor_id = 4
+    - BBB vendor_id = 1
+    - CCC vendor_id = 2
+
+  `c.dia`:
+  ```text
+  @vendor 3 C
+  @avp_types
+      DDD 444 Unsigned32 V
+  @inherits diameter_b
+  @avp_vendor_id 5
+      BBB
+      CCC
+  ```
+
+  `c.dia` will see:
+    - AAA vendor_id = 1
+    - BBB vendor_id = 5
+    - CCC vendor_id = 5
+    - DDD vendor_id = 3
+
+  In particular `b.dia`'s override of `AAA` to vendor_id = 4 is ignored by `c.dia` and `AAA` is
+  back to having vendor_id = 1.
+
 - **`@avp_types`{: #avp_types }** - Defines the name, code, type and flags of
   individual AVPs. The section consists of definitions of the form
 
@@ -291,6 +342,56 @@ order in which sections are specified is unimportant.
   REMOVE_SIP_SERVER        3
   ```
 
+  If `indirect_inherits` option from [codec/2](`diameter_make:codec/2`) is used,
+  new enum values can also be added in each `.dia` file along the inheritance chain,
+  example:
+
+  `a.dia`:
+  ```text
+  @avp_types
+      AAA 111 Enumerated V
+  @enum AAA
+      A 0
+      B 1
+  ```
+
+  `a.dia` will see following enum values:
+    - A 0
+    - B 1
+
+  `b.dia`:
+  ```text
+  @inherits diameter_a
+  @enum AAA
+      C 2
+      D 3
+  ```
+
+  `b.dia` will see following enum values:
+    - A 0
+    - B 1
+    - C 2
+    - D 3
+
+  `c.dia`:
+  ```text
+  @inherits diameter_b
+  @enum AAA
+      E 4
+      F 5
+  ```
+
+  `c.dia` will see:
+    - A 0
+    - B 1
+    - C 2
+    - D 3
+    - E 4
+    - F 5
+
+  Warning: messages are not shown in this example, but it is required to add
+  enum AVPs to messages in order for the code to encode/decode them to be generated!
+
 - **`@end`{: #end }** - Causes parsing of the dictionary to terminate: any
   remaining content is ignored.
 
diff --git a/lib/diameter/doc/references/diameterc_cmd.md b/lib/diameter/doc/references/diameterc_cmd.md
index d76aac3d7e..b85edf6c8e 100644
--- a/lib/diameter/doc/references/diameterc_cmd.md
+++ b/lib/diameter/doc/references/diameterc_cmd.md
@@ -45,7 +45,7 @@ source. Valid options are as follows.
 
 - **\-i <dir>** - Prepend the specified directory to the code path. Use to
   point at beam files compiled from inherited dictionaries,
-  `[@inherits](diameter_dict.md#inherits)` in a dictionary file creating a
+  [@inherits](diameter_dict.md#inherits) in a dictionary file creating a
   beam dependency, not an erl/hrl dependency.
 
   Multiple `-i` options can be specified.
@@ -60,11 +60,11 @@ source. Valid options are as follows.
 - **\--name <name>** - Name the output module.
 
 - **\--prefix <prefix>** - Transform the input dictionary before compilation,
-  setting `[@name](diameter_dict.md#name)` or
-  `[@prefix](diameter_dict.md#prefix)` to the specified string.
+  setting [@name](diameter_dict.md#name) or
+  [@prefix](diameter_dict.md#prefix) to the specified string.
 
 - **\--inherits <arg>** - Transform the input dictionary before compilation,
-  appending `[@inherits](diameter_dict.md#inherits)` of the specified string.
+  appending [@inherits](diameter_dict.md#inherits) of the specified string.
 
   Two forms of `--inherits` have special meaning:
 
@@ -80,6 +80,9 @@ source. Valid options are as follows.
 
   Multiple `--inherits` options can be specified.
 
+- **\--indirect-inherits** - Enables indirect inherits feature, see more
+  [here](`diameter_make:codec/2`).
+
 # EXIT STATUS
 
 Returns 0 on success, non-zero on failure.
diff --git a/lib/diameter/src/compiler/diameter_make.erl b/lib/diameter/src/compiler/diameter_make.erl
index c0d7b9198a..213afd3dfc 100644
--- a/lib/diameter/src/compiler/diameter_make.erl
+++ b/lib/diameter/src/compiler/diameter_make.erl
@@ -149,6 +149,26 @@ file or returned, and can have the following types.
 
   Multiple `inherits` options can be specified.
 
+- **`indirect_inherits`** - This option makes compiler support automatic
+  recursive inheritance. When a dictionary file inherits another `.dia`, all
+  ancestors of that `.dia` will also be considered in code generation. This
+  enhancement removes the requirement to explicitly list all parent dictionaries
+  via `@inherits`, preventing missing AVP/message encodings and runtime errors.
+
+  **Example** `C.dia` inherits `B.dia` and `B.dia` inherits `A.dia`.
+
+  **Before (without indirect_inherits):**
+
+  If `C.dia` references AVPs from `A.dia` without directly inheriting it,
+  the generated code will lack necessary definitions, causing encoding failures.
+
+  **After (with indirect_inherits):**
+
+  `C.dia` can reference AVPs from `A.dia` without directly inheriting it,
+  compiler will resolve the entire inheritance chain automatically, ensuring
+  all relevant descendant definitions from `A.dia` are available without
+  additional user declarations.  
+
 Note that a dictionary's [`@name`](diameter_dict.md#name), together with the
 `outdir` option, determine the output paths when the `return` option is not
 specified. The [`@name`](diameter_dict.md#name) of a literal input dictionary
-- 
2.51.0

openSUSE Build Service is sponsored by