Code is generated to take the address of the function instead of calling it

FPC[main] x64 Windows&Linux


program app;
{$mode objfpc}

procedure print(s: AnsiString);
begin
  WriteLn('Output: ', s);
end;

function test: AnsiString;
begin
  Result := 'kek';
end;

function test(_: boolean): AnsiString;
begin
  Result := test;
end;

function testA: AnsiString;
begin
  Result := 'A';
end;

begin
  print(test(True));
  print(test(True));
  print(test);
  print(test(True));

  print(testA);
  print(testA());

  {$ifdef windows}ReadLn;{$endif}
end.

Output:

Output:
Output:
Output: kek
Output: kek
Output: A
Output: A