From 0f2277e0138f15eaaa646f654523270bf536b4e9 Mon Sep 17 00:00:00 2001 From: "Alejandro R. Mosteo" Date: Fri, 17 Aug 2018 18:26:11 +0200 Subject: [PATCH] fix iterate on empty tree --- src/alire-conditional_trees.adb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/alire-conditional_trees.adb b/src/alire-conditional_trees.adb index 0204c52e..ffb43f7e 100644 --- a/src/alire-conditional_trees.adb +++ b/src/alire-conditional_trees.adb @@ -417,7 +417,9 @@ package body Alire.Conditional_Trees is ----------- overriding function First (Object : Forward_Iterator) return Cursor is - (Cursor (Object.Children.First)); + (if Object.Children.Is_Empty + then Cursor (Vectors.No_Element) + else Cursor (Object.Children.First)); ---------- -- Next -- @@ -448,6 +450,10 @@ package body Alire.Conditional_Trees is function Iterate (Container : Tree) return Iterators.Forward_Iterator'Class is begin + if Container.Is_Empty then + return Forward_Iterator'(others => <>); + end if; + if Container.Kind /= Vector then raise Constraint_Error with "Cannot iterate over non-vector conditional value";