Not accepting @ for function reference in Delphi mode
Summary
Sometimes compiler forgets to not accept @ for function reference.
Example Project
program Project1;
{$mode Delphi}
type
TTest = procedure(V: Integer);
procedure Test1(V: Integer);
begin
WriteLn('Test1: ', V);
end;
procedure Run;
procedure Test2(V: Integer);
begin
WriteLn('Test2: ', V);
end;
var
T: TTest;
begin
T := @Test2;
T(1); //Writes 0
end;
begin
Run;
ReadLn;
end.
What is the current bug behavior?
It should not accept @test2. And also, this sample:
program Project1;
{$mode Delphi}
{$modeswitch functionreferences}
type
TTest = reference to procedure(V: Integer);
procedure Test1(V: Integer);
begin
WriteLn('Test1: ', V);
end;
procedure Run;
procedure Test2(V: Integer);
begin
WriteLn('Test2: ', V);
end;
var
T: TTest;
begin
T := @Test2; //Error on Delphi mode but not objfpc
T(1);
end;
begin
Run;
ReadLn;
end.
What is the expected (correct) behavior?
Relevant logs and/or screenshots
https://forum.lazarus.freepascal.org/index.php/topic,59468.msg504943.html#msg504943