[fpc-devel] Issue with implicit function specialization
Hairy Pixels
genericptr at gmail.com
Sun Feb 19 03:49:33 CET 2023
The function Bind is specialized with two types which are identical (TState<Integer>) and the compiler can’t determine which to call.
Is there anyway to resolve this? In my mind I want the more “explicit” overload with the var parameter but there’s really no way for the compiler to know this, that I can think of anyways.
========================================
{$mode objfpc}
{$modeswitch implicitfunctionspecialization}
program test;
type
generic TState<T> = class
end;
generic procedure Bind<T>(value: T);
begin
end;
generic procedure Bind<T>(var state: specialize TState<T>);
begin
end;
var
state: specialize TState<Integer>;
begin
Bind(state); // Error: Can't determine which overloaded function to call
end.
Regards,
Ryan Joseph
More information about the fpc-devel
mailing list