mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-07 16:06:16 +02:00
* fix #40721: correctly set up the generic defs when parsing fields, especially important when dealing with anonymous fields
+ added tests
This commit is contained in:
parent
0e9efd07ef
commit
7a1ef994b4
@ -1684,7 +1684,7 @@ implementation
|
|||||||
sc : TFPObjectList;
|
sc : TFPObjectList;
|
||||||
i : longint;
|
i : longint;
|
||||||
hs,sorg : string;
|
hs,sorg : string;
|
||||||
hdef,casetype : tdef;
|
gendef,hdef,casetype : tdef;
|
||||||
{ maxsize contains the max. size of a variant }
|
{ maxsize contains the max. size of a variant }
|
||||||
{ startvarrec contains the start of the variant part of a record }
|
{ startvarrec contains the start of the variant part of a record }
|
||||||
maxsize, startvarrecsize : asizeint;
|
maxsize, startvarrecsize : asizeint;
|
||||||
@ -1782,7 +1782,23 @@ implementation
|
|||||||
|
|
||||||
typepos:=current_filepos;
|
typepos:=current_filepos;
|
||||||
|
|
||||||
read_anon_type(hdef,false,nil);
|
{ make sure that the correct genericdef is set up, especially if
|
||||||
|
we're dealing with anonymous type declarations }
|
||||||
|
gendef:=nil;
|
||||||
|
if df_specialization in current_structdef.defoptions then
|
||||||
|
begin
|
||||||
|
srsymtable:=current_structdef.genericdef.getsymtable(gs_record);
|
||||||
|
if not assigned(srsymtable) then
|
||||||
|
internalerror(2024041204);
|
||||||
|
srsym:=tsym(srsymtable.find(tabstractvarsym(sc[0]).name));
|
||||||
|
if not assigned(srsym) then
|
||||||
|
internalerror(2024041205);
|
||||||
|
if srsym.typ<>fieldvarsym then
|
||||||
|
internalerror(2024041206);
|
||||||
|
gendef:=tfieldvarsym(srsym).vardef;
|
||||||
|
end;
|
||||||
|
|
||||||
|
read_anon_type(hdef,false,tstoreddef(gendef));
|
||||||
maybe_guarantee_record_typesym(hdef,symtablestack.top);
|
maybe_guarantee_record_typesym(hdef,symtablestack.top);
|
||||||
{$ifdef wasm}
|
{$ifdef wasm}
|
||||||
if is_wasm_reference_type(hdef) then
|
if is_wasm_reference_type(hdef) then
|
||||||
|
18
tests/webtbs/tw40712a.pp
Normal file
18
tests/webtbs/tw40712a.pp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{ %NORUN }
|
||||||
|
|
||||||
|
program tw40712a;
|
||||||
|
{$mode objfpc}
|
||||||
|
type
|
||||||
|
generic TSomeGeneric<T> = object
|
||||||
|
type
|
||||||
|
TMine = T;
|
||||||
|
var
|
||||||
|
data: record
|
||||||
|
value: TMine;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
TSomeGeneric2 = object(specialize TSomeGeneric<Integer>)
|
||||||
|
end;
|
||||||
|
begin
|
||||||
|
end.
|
||||||
|
|
17
tests/webtbs/tw40712b.pp
Normal file
17
tests/webtbs/tw40712b.pp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{ %NORUN }
|
||||||
|
|
||||||
|
program tw40712b;
|
||||||
|
{$mode delphi}
|
||||||
|
type
|
||||||
|
TSomeGeneric<T> = object
|
||||||
|
type
|
||||||
|
TMine = T;
|
||||||
|
var
|
||||||
|
data: record
|
||||||
|
value: T;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
TSomeGeneric2 = object(TSomeGeneric<Integer>)
|
||||||
|
end;
|
||||||
|
begin
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user