[fpc-devel] Minor doc error about "const param"

Bart bartjunk64 at gmail.com
Fri Dec 24 18:07:30 CET 2021


On Fri, Dec 24, 2021 at 12:00 PM Adriaan van Os via fpc-devel
<fpc-devel at lists.freepascal.org> wrote:

> Neither would the compiler allow (I hope) the const parameter to be passed as a var parameter.

It does not:

{$mode objfpc}
{$h+}

procedure foo(var x: integer);
begin
end;

procedure bar(const y: integer);
begin
  foo(y); //line 10
end;

begin
end.

test.pas(10,8) Error: Can't assign values to const variable

-- 
Bart


More information about the fpc-devel mailing list