Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2021-12

Bug? "overload" between class.method and plain procedure ?

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin Frb

Should overload work for the following?
Upon seeing the method being overloaded, if (in the class hierarchy) no method  with matching signature is found, should procedures outside the class be searched?

project1.lpr(19,8) Error: Incompatible type for arg no. 1: Got

"ShortInt", expected "Boolean"

In the below example, I could write "project1.Foo(1); ". But if I had various "Foo" in various included units, then it would be inconvenient to always have to find the correct unit myself.

The doc https://www.freepascal.org/docs-html/ref/refsu86.html does not contain any references to classes. It only refers to cross unit.

program Project1;
{$mode objfpc}{$H+}
procedure Foo(a: integer); forward; overload;
type
   TBar = class
   public
     procedure Foo(a: boolean); overload;
     procedure Bar;
   end;
procedure TBar.Foo(a: boolean);
begin
end;
procedure TBar.Bar;
begin
   Foo(1); //project1.lpr(19,8) Error: Incompatible type for arg no. 1:
Got "ShortInt", expected "Boolean"
end;
procedure Foo(a: integer);
begin
end;
begin
end.

Reply by email