* fix #39860: even if the block type is not correct for the specialization of a generic routine continue to specialize it to not trigger e.g. an internal error

+ added tests
This commit is contained in:
Sven/Sarah Barth 2022-08-12 14:45:12 +02:00
parent 306559667c
commit 35958a9b6b
3 changed files with 33 additions and 12 deletions

View File

@ -3403,19 +3403,12 @@ implementation
if hdef.typ=procdef then
begin
if block_type<>bt_body then
begin
message(parser_e_illegal_expression);
srsym:=generrorsym;
srsymtable:=nil;
end
message(parser_e_illegal_expression);
srsym:=tprocdef(hdef).procsym;
if assigned(spezcontext.symtable) then
srsymtable:=spezcontext.symtable
else
begin
srsym:=tprocdef(hdef).procsym;
if assigned(spezcontext.symtable) then
srsymtable:=spezcontext.symtable
else
srsymtable:=srsym.owner;
end;
srsymtable:=srsym.owner;
end
else
internalerror(2015061204);

14
tests/webtbf/tw39860a.pp Normal file
View File

@ -0,0 +1,14 @@
{ %FAIL }
{$mode objfpc}
generic function Size<T>: SizeUint;
begin
result := sizeof(T);
end;
var
a: array[0 .. specialize Size<double> - 1] of byte;
begin
end.

14
tests/webtbf/tw39860b.pp Normal file
View File

@ -0,0 +1,14 @@
{ %FAIL }
{$mode delphi}
function Size<T>: SizeUint;
begin
result := sizeof(T);
end;
var
a: array[0 .. Size<double> - 1] of byte;
begin
end.