From ead882f58d4a99e73d6fe60ff0f4241fa9b685d9 Mon Sep 17 00:00:00 2001 From: Sven/Sarah Barth Date: Thu, 2 Jan 2025 13:23:21 +0100 Subject: [PATCH] * fix #40876: correctly check for generic constant parameters without concrete value + added test --- compiler/pgenutil.pas | 3 ++- tests/webtbs/tw40876.pp | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 tests/webtbs/tw40876.pp diff --git a/compiler/pgenutil.pas b/compiler/pgenutil.pas index 142391f06a..75c772755a 100644 --- a/compiler/pgenutil.pas +++ b/compiler/pgenutil.pas @@ -1688,7 +1688,8 @@ uses result:=False; if adef.genericparas<>nil then for i:=0 to adef.genericparas.Count-1 do - if sp_generic_para in tsym(adef.genericparas[i]).symoptions then + if ((tsym(adef.genericparas[i]).typ=typesym) and (sp_generic_para in tsym(adef.genericparas[i]).symoptions)) or + ((tsym(adef.genericparas[i]).typ=constsym) and not (sp_generic_const in tsym(adef.genericparas[i]).symoptions)) then exit(true); end; diff --git a/tests/webtbs/tw40876.pp b/tests/webtbs/tw40876.pp new file mode 100644 index 0000000000..a7f0b265c5 --- /dev/null +++ b/tests/webtbs/tw40876.pp @@ -0,0 +1,29 @@ +{ %NORUN } + +program tw40876; + +{$Mode Delphi} + +uses + SysUtils; + +type + TTest = record + public + function ToString(B: UInt64): UnicodeString; + end; + +// There should be at least one method for linking to fail +function TTest.ToString(B: UInt64): UnicodeString; +begin + Result := (A + B).ToString; +end; + +type + TMyTest = TTest<1234>; + +var A: TMyTest; +begin + WriteLn(A.ToString(23456)); +end. +