[fpc-pascal] Constants in generics tests

Ryan Joseph ryan at thealchemistguild.com
Sat Feb 16 16:32:54 CET 2019



> On Feb 16, 2019, at 9:42 AM, Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> 
> When you create the constant symbols for the specialization you need to make sure that they belong to the surrounding symtable, not the specialized generic. 
> 

I probably didn’t get that right then. The constants are significantly different because they are generated during specialization unlike normal types which are already defined and have ownerships.

Btw I just saw this (in types_dec from pdecl.pas) and not sure it applies to constants. The symbol in question here was created in parse_generic_parameters and tconstsym doesn’t have a typedef method so I don’t know what casting to ttypesym did. Maybe tconstsym.constdef needs to be registered but I have no idea.

 { we are not freeing the type parameters, so register them }
               for i:=0 to generictypelist.count-1 do
                 begin
                    ttypesym(generictypelist[i]).register_sym;
                    tstoreddef(ttypesym(generictypelist[i]).typedef).register_def;
                 end;

Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list