* fix #40876: correctly check for generic constant parameters without concrete value

+ added test
This commit is contained in:
Sven/Sarah Barth 2025-01-02 13:23:21 +01:00
parent c40dd8bdc1
commit ead882f58d
2 changed files with 31 additions and 1 deletions

View File

@ -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;

29
tests/webtbs/tw40876.pp Normal file
View File

@ -0,0 +1,29 @@
{ %NORUN }
program tw40876;
{$Mode Delphi}
uses
SysUtils;
type
TTest<const A: UInt64> = record
public
function ToString(B: UInt64): UnicodeString;
end;
// There should be at least one method for linking to fail
function TTest<A>.ToString(B: UInt64): UnicodeString;
begin
Result := (A + B).ToString;
end;
type
TMyTest = TTest<1234>;
var A: TMyTest;
begin
WriteLn(A.ToString(23456));
end.