From 2bce1932841933fbe2dc31026fd68e5bc7a9c96d Mon Sep 17 00:00:00 2001
From: Vadim Godunko <godunko@adacore.com>
Date: Mon, 9 Dec 2024 07:41:21 +0400
Subject: [PATCH] Fix Ada code to prevent raise of `Constraint_Error`

---
 .../markdown-blocks-atx_headings.adb          |  6 ++---
 .../markdown-blocks-fenced_code.adb           |  6 ++---
 .../implementation/markdown-blocks-html.adb   |  4 ++--
 .../markdown-blocks-indented_code.adb         |  6 ++---
 .../markdown-blocks-internals.adb             |  4 ++--
 .../implementation/markdown-blocks-lists.adb  |  7 +++---
 .../markdown-blocks-paragraphs.adb            |  6 ++---
 .../implementation/markdown-blocks-quotes.adb | 11 ++++++----
 .../implementation/markdown-blocks-tables.adb |  4 ++--
 .../markdown-blocks-thematic_breaks.adb       |  6 ++---
 .../parser/implementation/markdown-blocks.adb | 22 +++++++++----------
 .../implementation/markdown-documents.adb     |  7 ++++--
 .../markdown-implementation.adb               | 10 ++++-----
 .../markdown-implementation.ads               |  4 ++--
 .../markdown-list_items-internals.adb         |  4 ++--
 .../implementation/markdown-list_items.adb    | 13 ++++++-----
 .../implementation/markdown-parsers.adb       |  8 ++++---
 17 files changed, 70 insertions(+), 58 deletions(-)

diff --git a/source/parser/implementation/markdown-blocks-atx_headings.adb b/source/parser/implementation/markdown-blocks-atx_headings.adb
index 6df7413..e862a7b 100644
--- a/source/parser/implementation/markdown-blocks-atx_headings.adb
+++ b/source/parser/implementation/markdown-blocks-atx_headings.adb
@@ -1,5 +1,5 @@
 --
---  Copyright (C) 2021-2023, AdaCore
+--  Copyright (C) 2021-2024, AdaCore
 --
 --  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 --
@@ -14,7 +14,7 @@ package body Markdown.Blocks.ATX_Headings is
 
    overriding procedure Adjust (Self : in out ATX_Heading) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          System.Atomic_Counters.Increment (Self.Data.Counter);
       end if;
    end Adjust;
@@ -25,7 +25,7 @@ package body Markdown.Blocks.ATX_Headings is
 
    overriding procedure Finalize (Self : in out ATX_Heading) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          if System.Atomic_Counters.Decrement (Self.Data.Counter) then
             Markdown.Implementation.Free
               (Markdown.Implementation.Abstract_Block_Access (Self.Data));
diff --git a/source/parser/implementation/markdown-blocks-fenced_code.adb b/source/parser/implementation/markdown-blocks-fenced_code.adb
index 8708a5b..862d1a4 100644
--- a/source/parser/implementation/markdown-blocks-fenced_code.adb
+++ b/source/parser/implementation/markdown-blocks-fenced_code.adb
@@ -1,5 +1,5 @@
 --
---  Copyright (C) 2021-2023, AdaCore
+--  Copyright (C) 2021-2024, AdaCore
 --
 --  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 --
@@ -14,7 +14,7 @@ package body Markdown.Blocks.Fenced_Code is
 
    overriding procedure Adjust (Self : in out Fenced_Code_Block) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          System.Atomic_Counters.Increment (Self.Data.Counter);
       end if;
    end Adjust;
@@ -25,7 +25,7 @@ package body Markdown.Blocks.Fenced_Code is
 
    overriding procedure Finalize (Self : in out Fenced_Code_Block) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          if System.Atomic_Counters.Decrement (Self.Data.Counter) then
             Markdown.Implementation.Free
               (Markdown.Implementation.Abstract_Block_Access (Self.Data));
diff --git a/source/parser/implementation/markdown-blocks-html.adb b/source/parser/implementation/markdown-blocks-html.adb
index 4b17f26..7cf180c 100644
--- a/source/parser/implementation/markdown-blocks-html.adb
+++ b/source/parser/implementation/markdown-blocks-html.adb
@@ -14,7 +14,7 @@ package body Markdown.Blocks.HTML is
 
    overriding procedure Adjust (Self : in out HTML_Block) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          System.Atomic_Counters.Increment (Self.Data.Counter);
       end if;
    end Adjust;
@@ -25,7 +25,7 @@ package body Markdown.Blocks.HTML is
 
    overriding procedure Finalize (Self : in out HTML_Block) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          if System.Atomic_Counters.Decrement (Self.Data.Counter) then
             Markdown.Implementation.Free
               (Markdown.Implementation.Abstract_Block_Access (Self.Data));
diff --git a/source/parser/implementation/markdown-blocks-indented_code.adb b/source/parser/implementation/markdown-blocks-indented_code.adb
index a8ed8cb..9cdd018 100644
--- a/source/parser/implementation/markdown-blocks-indented_code.adb
+++ b/source/parser/implementation/markdown-blocks-indented_code.adb
@@ -1,5 +1,5 @@
 --
---  Copyright (C) 2021-2023, AdaCore
+--  Copyright (C) 2021-2024, AdaCore
 --
 --  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 --
@@ -14,7 +14,7 @@ package body Markdown.Blocks.Indented_Code is
 
    overriding procedure Adjust (Self : in out Indented_Code_Block) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          System.Atomic_Counters.Increment (Self.Data.Counter);
       end if;
    end Adjust;
@@ -25,7 +25,7 @@ package body Markdown.Blocks.Indented_Code is
 
    overriding procedure Finalize (Self : in out Indented_Code_Block) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          if System.Atomic_Counters.Decrement (Self.Data.Counter) then
             Markdown.Implementation.Free
               (Markdown.Implementation.Abstract_Block_Access (Self.Data));
diff --git a/source/parser/implementation/markdown-blocks-internals.adb b/source/parser/implementation/markdown-blocks-internals.adb
index 9d93e08..0492b9b 100644
--- a/source/parser/implementation/markdown-blocks-internals.adb
+++ b/source/parser/implementation/markdown-blocks-internals.adb
@@ -1,5 +1,5 @@
 --
---  Copyright (C) 2021-2023, AdaCore
+--  Copyright (C) 2021-2024, AdaCore
 --
 --  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 --
@@ -14,7 +14,7 @@ package body Markdown.Blocks.Internals is
      (Self : in out Block;
       Data : Markdown.Implementation.Abstract_Block_Access) is
    begin
-      pragma Assert (not Self.Data.Assigned);
+      pragma Assert (not Markdown.Implementation.Is_Assigned (Self.Data));
       Self.Data := Data;
    end Set;
 
diff --git a/source/parser/implementation/markdown-blocks-lists.adb b/source/parser/implementation/markdown-blocks-lists.adb
index 916cacf..e035129 100644
--- a/source/parser/implementation/markdown-blocks-lists.adb
+++ b/source/parser/implementation/markdown-blocks-lists.adb
@@ -16,7 +16,7 @@ package body Markdown.Blocks.Lists is
 
    overriding procedure Adjust (Self : in out List) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          System.Atomic_Counters.Increment (Self.Data.Counter);
       end if;
    end Adjust;
@@ -50,7 +50,7 @@ package body Markdown.Blocks.Lists is
 
    overriding procedure Finalize (Self : in out List) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          if System.Atomic_Counters.Decrement (Self.Data.Counter) then
             Markdown.Implementation.Free
               (Markdown.Implementation.Abstract_Block_Access (Self.Data));
@@ -115,7 +115,8 @@ package body Markdown.Blocks.Lists is
    function Length (Self : List) return Natural is
    begin
       return
-        (if Self.Data.Assigned then Self.Data.Children.Last_Index else 0);
+        (if Markdown.Implementation.Is_Assigned (Self.Data)
+           then Self.Data.Children.Last_Index else 0);
    end Length;
 
    ----------
diff --git a/source/parser/implementation/markdown-blocks-paragraphs.adb b/source/parser/implementation/markdown-blocks-paragraphs.adb
index 82deaef..4eb1bd1 100644
--- a/source/parser/implementation/markdown-blocks-paragraphs.adb
+++ b/source/parser/implementation/markdown-blocks-paragraphs.adb
@@ -1,5 +1,5 @@
 --
---  Copyright (C) 2021-2023, AdaCore
+--  Copyright (C) 2021-2024, AdaCore
 --
 --  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 --
@@ -14,7 +14,7 @@ package body Markdown.Blocks.Paragraphs is
 
    overriding procedure Adjust (Self : in out Paragraph) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          System.Atomic_Counters.Increment (Self.Data.Counter);
       end if;
    end Adjust;
@@ -25,7 +25,7 @@ package body Markdown.Blocks.Paragraphs is
 
    overriding procedure Finalize (Self : in out Paragraph) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          if System.Atomic_Counters.Decrement (Self.Data.Counter) then
             Markdown.Implementation.Free
               (Markdown.Implementation.Abstract_Block_Access (Self.Data));
diff --git a/source/parser/implementation/markdown-blocks-quotes.adb b/source/parser/implementation/markdown-blocks-quotes.adb
index d775c73..020d4a7 100644
--- a/source/parser/implementation/markdown-blocks-quotes.adb
+++ b/source/parser/implementation/markdown-blocks-quotes.adb
@@ -55,8 +55,8 @@ package body Markdown.Blocks.Quotes is
      return Quote is
    begin
       pragma Assert
-        (not Self.Data.Assigned or else
-           Self.Data.all in Implementation.Quotes.Quote'Class);
+        (not Markdown.Implementation.Is_Assigned (Self.Data)
+           or else Self.Data.all in Implementation.Quotes.Quote'Class);
 
       System.Atomic_Counters.Increment (Self.Data.Counter);
 
@@ -71,7 +71,9 @@ package body Markdown.Blocks.Quotes is
 
    overriding function Is_Empty (Self : Quote) return Boolean is
    begin
-      return not Self.Data.Assigned or else Self.Data.Children.Is_Empty;
+      return
+        not Markdown.Implementation.Is_Assigned (Self.Data)
+          or else Self.Data.Children.Is_Empty;
    end Is_Empty;
 
    ------------
@@ -81,7 +83,8 @@ package body Markdown.Blocks.Quotes is
    overriding function Length (Self : Quote) return Natural is
    begin
       return
-        (if Self.Data.Assigned then Self.Data.Children.Last_Index else 0);
+        (if Markdown.Implementation.Is_Assigned (Self.Data)
+           then Self.Data.Children.Last_Index else 0);
    end Length;
 
    --------------
diff --git a/source/parser/implementation/markdown-blocks-tables.adb b/source/parser/implementation/markdown-blocks-tables.adb
index b3f6edf..db360e1 100644
--- a/source/parser/implementation/markdown-blocks-tables.adb
+++ b/source/parser/implementation/markdown-blocks-tables.adb
@@ -14,7 +14,7 @@ package body Markdown.Blocks.Tables is
 
    overriding procedure Adjust (Self : in out Table) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          System.Atomic_Counters.Increment (Self.Data.Counter);
       end if;
    end Adjust;
@@ -48,7 +48,7 @@ package body Markdown.Blocks.Tables is
 
    overriding procedure Finalize (Self : in out Table) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          if System.Atomic_Counters.Decrement (Self.Data.Counter) then
             Markdown.Implementation.Free
               (Markdown.Implementation.Abstract_Block_Access (Self.Data));
diff --git a/source/parser/implementation/markdown-blocks-thematic_breaks.adb b/source/parser/implementation/markdown-blocks-thematic_breaks.adb
index 2d72e13..0c397bd 100644
--- a/source/parser/implementation/markdown-blocks-thematic_breaks.adb
+++ b/source/parser/implementation/markdown-blocks-thematic_breaks.adb
@@ -1,5 +1,5 @@
 --
---  Copyright (C) 2021-2023, AdaCore
+--  Copyright (C) 2021-2024, AdaCore
 --
 --  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 --
@@ -14,7 +14,7 @@ package body Markdown.Blocks.Thematic_Breaks is
 
    overriding procedure Adjust (Self : in out Thematic_Break) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          System.Atomic_Counters.Increment (Self.Data.Counter);
       end if;
    end Adjust;
@@ -25,7 +25,7 @@ package body Markdown.Blocks.Thematic_Breaks is
 
    overriding procedure Finalize (Self : in out Thematic_Break) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          if System.Atomic_Counters.Decrement (Self.Data.Counter) then
             Markdown.Implementation.Free
               (Markdown.Implementation.Abstract_Block_Access (Self.Data));
diff --git a/source/parser/implementation/markdown-blocks.adb b/source/parser/implementation/markdown-blocks.adb
index 3f2e307..fd82e17 100644
--- a/source/parser/implementation/markdown-blocks.adb
+++ b/source/parser/implementation/markdown-blocks.adb
@@ -33,7 +33,7 @@ package body Markdown.Blocks is
 
    overriding procedure Adjust (Self : in out Block) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          System.Atomic_Counters.Increment (Self.Data.Counter);
       end if;
    end Adjust;
@@ -44,7 +44,7 @@ package body Markdown.Blocks is
 
    overriding procedure Finalize (Self : in out Block) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          if System.Atomic_Counters.Decrement (Self.Data.Counter) then
             Markdown.Implementation.Free (Self.Data);
 
@@ -60,7 +60,7 @@ package body Markdown.Blocks is
 
    function Is_ATX_Heading (Self : Block'Class) return Boolean is
    begin
-      return Self.Data.Assigned
+      return Markdown.Implementation.Is_Assigned (Self.Data)
         and then Self.Data.all in
           Implementation.ATX_Headings.ATX_Heading'Class;
    end Is_ATX_Heading;
@@ -71,7 +71,7 @@ package body Markdown.Blocks is
 
    function Is_Fenced_Code_Block (Self : Block'Class) return Boolean is
    begin
-      return Self.Data.Assigned
+      return Markdown.Implementation.Is_Assigned (Self.Data)
         and then Self.Data.all in
           Implementation.Fenced_Code_Blocks.Fenced_Code_Block'Class;
    end Is_Fenced_Code_Block;
@@ -82,7 +82,7 @@ package body Markdown.Blocks is
 
    function Is_HTML_Block (Self : Block'Class) return Boolean is
    begin
-      return Self.Data.Assigned
+      return Markdown.Implementation.Is_Assigned (Self.Data)
         and then Self.Data.all in
           Implementation.HTML_Blocks.HTML_Block'Class;
    end Is_HTML_Block;
@@ -93,7 +93,7 @@ package body Markdown.Blocks is
 
    function Is_Indented_Code_Block (Self : Block'Class) return Boolean is
    begin
-      return Self.Data.Assigned
+      return Markdown.Implementation.Is_Assigned (Self.Data)
         and then Self.Data.all in
           Implementation.Indented_Code_Blocks.Indented_Code_Block'Class;
    end Is_Indented_Code_Block;
@@ -104,7 +104,7 @@ package body Markdown.Blocks is
 
    function Is_List (Self : Block'Class) return Boolean is
    begin
-      return Self.Data.Assigned
+      return Markdown.Implementation.Is_Assigned (Self.Data)
         and then Self.Data.all in
           Markdown.Implementation.Lists.List;
    end Is_List;
@@ -115,7 +115,7 @@ package body Markdown.Blocks is
 
    function Is_Paragraph (Self : Block'Class) return Boolean is
    begin
-      return Self.Data.Assigned
+      return Markdown.Implementation.Is_Assigned (Self.Data)
         and then Self.Data.all in
           Markdown.Implementation.Paragraphs.Paragraph'Class
         and then Markdown.Implementation.Paragraphs.Paragraph'Class
@@ -128,7 +128,7 @@ package body Markdown.Blocks is
 
    function Is_Quote (Self : Block'Class) return Boolean is
    begin
-      return Self.Data.Assigned
+      return Markdown.Implementation.Is_Assigned (Self.Data)
         and then Self.Data.all in
           Markdown.Implementation.Quotes.Quote;
    end Is_Quote;
@@ -139,7 +139,7 @@ package body Markdown.Blocks is
 
    function Is_Table (Self : Block'Class) return Boolean is
    begin
-      return Self.Data.Assigned
+      return Markdown.Implementation.Is_Assigned (Self.Data)
         and then Self.Data.all in
           Markdown.Implementation.Paragraphs.Paragraph'Class
         and then Markdown.Implementation.Paragraphs.Paragraph'Class
@@ -152,7 +152,7 @@ package body Markdown.Blocks is
 
    function Is_Thematic_Break (Self : Block'Class) return Boolean is
    begin
-      return Self.Data.Assigned
+      return Markdown.Implementation.Is_Assigned (Self.Data)
         and then Self.Data.all in
           Markdown.Implementation.Thematic_Breaks.Thematic_Break;
    end Is_Thematic_Break;
diff --git a/source/parser/implementation/markdown-documents.adb b/source/parser/implementation/markdown-documents.adb
index 12698b2..c0e8de8 100644
--- a/source/parser/implementation/markdown-documents.adb
+++ b/source/parser/implementation/markdown-documents.adb
@@ -58,7 +58,9 @@ package body Markdown.Documents is
 
    overriding function Is_Empty (Self : Document) return Boolean is
    begin
-      return not Self.Data.Assigned or else Self.Data.Children.Is_Empty;
+      return
+        not Markdown.Implementation.Is_Assigned (Self.Data)
+          or else Self.Data.Children.Is_Empty;
    end Is_Empty;
 
    ------------
@@ -68,7 +70,8 @@ package body Markdown.Documents is
    overriding function Length (Self : Document) return Natural is
    begin
       return
-        (if Self.Data.Assigned then Self.Data.Children.Last_Index else 0);
+        (if Markdown.Implementation.Is_Assigned (Self.Data)
+           then Self.Data.Children.Last_Index else 0);
    end Length;
 
 end Markdown.Documents;
diff --git a/source/parser/implementation/markdown-implementation.adb b/source/parser/implementation/markdown-implementation.adb
index 937d2ab..98f812c 100644
--- a/source/parser/implementation/markdown-implementation.adb
+++ b/source/parser/implementation/markdown-implementation.adb
@@ -1,5 +1,5 @@
 --
---  Copyright (C) 2021-2023, AdaCore
+--  Copyright (C) 2021-2024, AdaCore
 --
 --  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 --
@@ -71,7 +71,7 @@ package body Markdown.Implementation is
 
    procedure Reference (Self : Abstract_Block_Access) is
    begin
-      if Self.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self) then
          System.Atomic_Counters.Increment (Self.Counter);
       end if;
    end Reference;
@@ -82,7 +82,7 @@ package body Markdown.Implementation is
 
    procedure Reference (Self : Abstract_Container_Block_Access) is
    begin
-      if Self.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self) then
          System.Atomic_Counters.Increment (Self.Counter);
       end if;
    end Reference;
@@ -133,10 +133,10 @@ package body Markdown.Implementation is
         (Markdown.Implementation.Abstract_Container_Block'Class,
          Abstract_Container_Block_Access);
    begin
-      if not Self.Assigned then
+      if not Markdown.Implementation.Is_Assigned (Self) then
          null;
-      elsif System.Atomic_Counters.Decrement (Self.Counter) then
 
+      elsif System.Atomic_Counters.Decrement (Self.Counter) then
          for Item of Self.Children loop
             if System.Atomic_Counters.Decrement (Item.Counter) then
                Markdown.Implementation.Free (Item);
diff --git a/source/parser/implementation/markdown-implementation.ads b/source/parser/implementation/markdown-implementation.ads
index 3a89fa8..3107a4c 100644
--- a/source/parser/implementation/markdown-implementation.ads
+++ b/source/parser/implementation/markdown-implementation.ads
@@ -1,5 +1,5 @@
 --
---  Copyright (C) 2021-2023, AdaCore
+--  Copyright (C) 2021-2024, AdaCore
 --
 --  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 --
@@ -33,7 +33,7 @@ package Markdown.Implementation is
    end record
      with No_Task_Parts;
 
-   function Assigned (Value : access Abstract_Block'Class) return Boolean is
+   function Is_Assigned (Value : access Abstract_Block'Class) return Boolean is
      (Value /= null);
    --  If Value is not null
 
diff --git a/source/parser/implementation/markdown-list_items-internals.adb b/source/parser/implementation/markdown-list_items-internals.adb
index 41d2a9a..da8b0c9 100644
--- a/source/parser/implementation/markdown-list_items-internals.adb
+++ b/source/parser/implementation/markdown-list_items-internals.adb
@@ -1,5 +1,5 @@
 --
---  Copyright (C) 2021-2023, AdaCore
+--  Copyright (C) 2021-2024, AdaCore
 --
 --  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 --
@@ -14,7 +14,7 @@ package body Markdown.List_Items.Internals is
      (Self : in out List_Item;
       Data : Markdown.Implementation.Abstract_Block_Access) is
    begin
-      pragma Assert (not Self.Data.Assigned);
+      pragma Assert (not Markdown.Implementation.Is_Assigned (Self.Data));
       Self.Data :=
         Markdown.Implementation.List_Items.List_Item_Access (Data);
    end Set;
diff --git a/source/parser/implementation/markdown-list_items.adb b/source/parser/implementation/markdown-list_items.adb
index 793c212..f37db7a 100644
--- a/source/parser/implementation/markdown-list_items.adb
+++ b/source/parser/implementation/markdown-list_items.adb
@@ -1,5 +1,5 @@
 --
---  Copyright (C) 2021-2023, AdaCore
+--  Copyright (C) 2021-2024, AdaCore
 --
 --  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 --
@@ -16,7 +16,7 @@ package body Markdown.List_Items is
 
    overriding procedure Adjust (Self : in out List_Item) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          System.Atomic_Counters.Increment (Self.Data.Counter);
       end if;
    end Adjust;
@@ -44,7 +44,7 @@ package body Markdown.List_Items is
 
    overriding procedure Finalize (Self : in out List_Item) is
    begin
-      if Self.Data.Assigned then
+      if Markdown.Implementation.Is_Assigned (Self.Data) then
          if System.Atomic_Counters.Decrement (Self.Data.Counter) then
             Markdown.Implementation.Free
               (Markdown.Implementation.Abstract_Block_Access (Self.Data));
@@ -61,7 +61,9 @@ package body Markdown.List_Items is
 
    overriding function Is_Empty (Self : List_Item) return Boolean is
    begin
-      return not Self.Data.Assigned or else Self.Data.Children.Is_Empty;
+      return
+        not Markdown.Implementation.Is_Assigned (Self.Data)
+          or else Self.Data.Children.Is_Empty;
    end Is_Empty;
 
    ----------------
@@ -80,7 +82,8 @@ package body Markdown.List_Items is
    overriding function Length (Self : List_Item) return Natural is
    begin
       return
-        (if Self.Data.Assigned then Self.Data.Children.Last_Index else 0);
+        (if Markdown.Implementation.Is_Assigned (Self.Data)
+           then Self.Data.Children.Last_Index else 0);
    end Length;
 
 end Markdown.List_Items;
diff --git a/source/parser/implementation/markdown-parsers.adb b/source/parser/implementation/markdown-parsers.adb
index 5eed191..379bc77 100644
--- a/source/parser/implementation/markdown-parsers.adb
+++ b/source/parser/implementation/markdown-parsers.adb
@@ -175,7 +175,7 @@ package body Markdown.Parsers is
       --  Try to append Input to Self.Open_Leaf if any, taking CIP into account
       if not Match then
          Self.Open_Leaf := null;
-      elsif Self.Open_Leaf.Assigned then
+      elsif Markdown.Implementation.Is_Assigned (Self.Open_Leaf) then
          Match := False;
          Self.Open_Leaf.Append_Line (Input, CIP, Match);
 
@@ -189,7 +189,9 @@ package body Markdown.Parsers is
 
       --  Otherwise create new blocks
       if not Done and Input.First.Has_Element then
-         while Tag /= Ada.Tags.No_Tag and not New_Leaf.Assigned loop
+         while Tag /= Ada.Tags.No_Tag
+           and not Markdown.Implementation.Is_Assigned (New_Leaf)
+         loop
             Create_Block (Input, Tag, New_Containers, New_Leaf);
             Self.Find_Block_Start (Input, Tag, CIP);
          end loop;
@@ -200,7 +202,7 @@ package body Markdown.Parsers is
 
       Self.Open.Move (Source => Open);  --  Replace Self.Open with Open
 
-      if New_Leaf.Assigned then
+      if Markdown.Implementation.Is_Assigned (New_Leaf) then
          if New_Containers.Is_Empty then
             Self.Open.Last_Element.Children.Append (New_Leaf);
          end if;
