Skip to content

Default value of the procedure/function parameter.

Original Reporter info from Mantis: avk @avk959
  • Reporter name: avk

Description:

This example does not compile in delphi mode, but does compile successfully in objfpc mode.

program def_param;
{$mode delphi}
function GTest<T>(a: T; b: T = T(1)): T;
begin
  Result := a + b;
end;

function Foobar(a: Single; b: Single = Single(1)): Single;
begin
  Result := a + b;
end;

begin
  WriteLn(GTest<Single>(2, 1));
  WriteLn(Foobar(2));
end. 

Current trunk compiles the example successfully in both modes.

Mantis conversion info:

  • Mantis ID: 37380
  • OS: linux
  • Build: 45770
  • Platform: x86_64
  • Version: 3.2.0
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information