[fpc-pascal] generic proc inference

Ryan Joseph genericptr at gmail.com
Mon Oct 7 16:00:36 CEST 2019



> On Oct 7, 2019, at 1:54 AM, Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> 
> There is nothing debatable here. If a generic parameter is not used in the parameter list (cause it's used in the result type (either directly or to specialize something else), only the body of the routine or even not at all), then that routine must not be used for implicit specialization. 
> 

Yeah I got it now. I’ll make an ambiguous error message in this case. Right now the cases the will trigger it are:

1) generic functions that have the same name/parameter list, regardless of generic parameters. This is an “Ambiguous call to DoThis” error. 

	generic function DoThis<T>(a: T): T;
	generic procedure DoThis<T>(a: T; b: integer = 100);
	generic function DoThis<T,U>(a: T): U;
	generic procedure DoThis<T,U,S>(a: T);
	var 
		field: S; 

2) Parameter not in function parameter list. Not sure yet but something like “DoThis can not infer specialization from parameter list”.
	generic function DoThis<T>(a: integer): T;

If there’s more let me know.

Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list