View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0037259||FPC||Compiler||public||2020-06-26 03:17||2020-06-27 23:13|
|Reporter||dmz73||Assigned To||Sven Barth|
|Summary||0037259: Compiler reports error "Can't determine which overloaded function to call" when one parameter is generic|
|Description||Generic record contains overloaded procedure where number of parameters is the same and one parameter in one procedure is generic.|
Calling this procedure from within the record results in error "Can't determine which overloaded function to call".
This same code compiles in Delphi.
|Steps To Reproduce||Compile the following example project:|
TRec<T> = record
procedure SetRec(A1: boolean; A2: string); overload;
procedure SetRec(A1: boolean; A4: T); overload;
procedure TRec<T>.SetRec(A1: boolean; A2: string);
procedure TRec<T>.SetRec(A1: boolean; A4: T);
Self.SetRec(true, default(T)); // error is reported here
|Additional Information||I have tried to compile the example project in the latest trunk version and it still reports the same error.|
|Fixed in Revision|
I would like you to reconsider the severity of this issue, I believe this is a major issue and almost a showstopper for anyone using generics in a serious way specially in code that has been created with Delphi.
For FPC alone this issue makes overloaded functions almost impossible to use with generics.
In Delphi they have taken a pragmatic approach and when there is a specific type and generic type version of a function that compiler could choose, the compiler will choose the specific type function. This makes it very easy to write generic code with few special cases. In FPC one has to be very careful not to create conflicting overloads and then create a generic function with lots of IF THEN ELSE IF code just to work around broken compiler.