[fpc-devel] Implicit function specialization precedence
Ryan Joseph
genericptr at gmail.com
Wed Apr 7 23:21:31 CEST 2021
With the requested changes I believe some precedence rules have changed. These both should be "Can't determine which overloaded function to call" errors or the non-generic should take precedence because the functions are ambiguous (by appearance at least). Currently the compiler thinks DoThis<T> is better than the non-generic and this may be because it was specialized as DoThis<ShortInt> because the parameter of "1" is a ShortInt.
What should the rule be here?
=====================
procedure DoThis(a: word; b: word);
begin
end;
generic procedure DoThis<T>(a:T; b: word);
begin
end;
begin
DoThis(1,1); // DoThis<T>
end.
=====================
generic procedure DoThis<T>(a:T; b: word);
begin
end;
generic procedure DoThis<T>(a: word; b: T);
begin
end;
begin
DoThis(1,1); // Can't determine which overloaded function to call
end.
=====================
Regards,
Ryan Joseph
More information about the fpc-devel
mailing list