Generics

It seems this is a bug? It should work but it doesn’t for some reason.

namespace ConsoleApplication4;
 
interface
 
procedure ToString<T>(const A: T);

implementation

procedure ToString<T>(const A: T);
begin
  case typeOf(T) of
    Integer: writeLn('Using type Integer');
    String: writeLn('Using type String');
  end;
end;
 
begin
    ToString<Integer>(1);
end.

What do you expect to happen and what does happen?

It should print out the type, currently nothing is printed out.
Seems like case is optimized out?

reproduced; it hits the else. will log for investigation.

1 Like

Logged as bugs://E26802.

1 Like