Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2023-02

Issue with implicit function specialization

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Hairy Pixels

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

Reply by email