From the doc https://www.freepascal.org/docs-html/current/ref/refsu62.html#x172-19600013.2.8
any variable reference, or method reference is checked to see if it is a field or method of the record or object or class

In the below code both objects have a "procedure def;", but they differ in their arguments.

So according to the doc, it checks if "foo()" (empty args) is on TX.
It is not, so should it then find "TBar.foo()"?

The issue also happens, if TBar.foo take a boolean arg, and the call is "foo(true)". So "empty" is not a special case.


Just to add: I just came across it while testing something else. I don't need this. I actually wonder if it is better as it is, since allowing it introduces new risks...
Though then, maybe the docs should state the intention.
No idea WDD.



program Project1;
{$mode objfpc}{$H+}
type

  TBar = class
    procedure def; overload;
  end;

  TX = class
    procedure def(a: integer); overload;
  end;

procedure TX.def(a: integer);overload;
begin
end;

procedure TBar.def;overload;
begin
end;

var
  b: TBar;
  x: TX;

begin
  with b do
    with x do
      def;
end.

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to