From 7120d74eec8a8d64f06253eec2763aec4f44ac6c Mon Sep 17 00:00:00 2001
From: Tristan Gingold <tgingold@free.fr>
Date: Mon, 2 Jan 2023 19:40:29 +0100
Subject: synth: adjust exec_name_subtype for function calls

---
 src/synth/elab-vhdl_expr.adb | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/synth/elab-vhdl_expr.adb b/src/synth/elab-vhdl_expr.adb
index 34b3fe621..1119f6ae9 100644
--- a/src/synth/elab-vhdl_expr.adb
+++ b/src/synth/elab-vhdl_expr.adb
@@ -374,8 +374,15 @@ package body Elab.Vhdl_Expr is
             end;
          when Iir_Kind_Function_Call =>
             declare
+               Ret_Typ : Type_Acc;
                Val : Valtyp;
             begin
+               Ret_Typ := Get_Subtype_Object (Syn_Inst, Get_Type (Name));
+               if Is_Bounded_Type (Ret_Typ) then
+                  return Ret_Typ;
+               end if;
+
+               --  Humm, is it an error ?
                Val := Synth.Vhdl_Expr.Synth_Expression (Syn_Inst, Name);
                return Val.Typ;
             end;
-- 
cgit v1.2.3