mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-03 20:18:35 +02:00
* fix #40876: correctly check for generic constant parameters without concrete value
+ added test
This commit is contained in:
parent
c40dd8bdc1
commit
ead882f58d
@ -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
29
tests/webtbs/tw40876.pp
Normal 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.
|
||||
|
Loading…
Reference in New Issue
Block a user