From a641860fa84fb2686b1360723b13625f6ac1866e Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Tue, 3 Jan 2023 21:17:58 +0100 Subject: [PATCH] Implicit specialisation: use regular array parameters for array constructors Fixes compilation of test/timpfuncspez5 with LLVM and debug info, as the LLVM debug info writer internalerror's when you try to generate debug info for an array constructor (since those types should never appear as parameter/ variable types). Replace them with reusable regular array types, so that multiple invocations of the same generic function with array constructors of the same type and number of elements are collapsed into the same specialisation --- compiler/pgenutil.pas | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compiler/pgenutil.pas b/compiler/pgenutil.pas index fd37efe3bd..281560c03b 100644 --- a/compiler/pgenutil.pas +++ b/compiler/pgenutil.pas @@ -763,6 +763,13 @@ uses newtype:=tstringdef(def).get_default_string_type.typesym else begin + if is_array_constructor(def) then + begin + { array constructor is not a valid parameter type; getreusable + avoids creating multiple implementations for calls with the + same number of array elements of a particular type } + def:=carraydef.getreusable(tarraydef(def).elementdef,tarraydef(def).highrange-tarraydef(def).lowrange+1); + end; newtype:=ctypesym.create(def.fullownerhierarchyname(false)+typName[def.typ]+'$'+def.unique_id_str,def); include(newtype.symoptions,sp_generic_unnamed_type); newtype.owner:=def.owner;