Well, the compiler can, or better the rtl can.
You just need to include the sysutils unit for a wealth of conversions.
Note that from a compiler point of view, you can not expect type inference for everything, but there are some tricks in fpc - not delphi - that I will add here
later.
{$mode objfpc}{$H+}
uses
sysutils;
// assign a string to an integer. string must be valid integer representation
operator := (const b:string):integer;inline;
begin
result := b.tointeger;
end;
// assign an integer to a string
operator := (const b:integer):string;inline;
begin
result := b.tostring;
end;
begin
writeln('100'.ToInteger);
writeln(100.ToString);
end.
As long as the string can be represented as an integer it becomes an integer on assignment
The integer will be simply represented as a string on assignment.
This can be done for almost all and any types.
So, yes, as the example proves, Freepascal supports type inference, but not all conversions are out of the box. You have to put in some work for now.