Sign in Join

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

Mailing lists / fpc-devel / 2014-01

Black List of examples that FPC won't compile.

8 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

Maciej Izak

Hi,

As always I am working on new Generics.* and I found very annoying bug.

Essence: http://bugs.freepascal.org/file_download.php?file_id=19514&type=bug Examples:
http://bugs.freepascal.org/file_download.php?file_id=19513&type=bug Bugtracker: http://bugs.freepascal.org/view.php?id=25607

Now to workaround this I must have more than ~50 needless constructors in Generics.*... and few hundred (!) needless methods in other libraries.

Should I live with this? Is there a chance that someone besides me considers this as a bug?

Regards,
HNB

Reply by email

Sven Barth
to Maciej Izak
"Maciej Izak" wrote 6 lines
Hi, As always I am working on new Generics.* and I found very annoying bug. Essence:

http://bugs.freepascal.org/file_download.php?file_id=19514&type=bug

Examples:

http://bugs.freepascal.org/file_download.php?file_id=19513&type=bug

Bugtracker: http://bugs.freepascal.org/view.php?id=25607 Now to workaround this I must have more than ~50 needless constructors in

Generics.*... and few hundred (!) needless methods in other libraries.

Should I live with this? Is there a chance that someone besides me

considers this as a bug?

You just published your results today (and submitted the report yesterday), so please be a bit patient...

Regards,
Sven

Reply by email

Florian Klämpfl
to Maciej Izak: As always I am working on new Generics.* and I found very annoying bug. Essence:…
Maciej Izak wrote 13 lines
Hi, As always I am working on new Generics.* and I found very annoying bug. Essence: http://bugs.freepascal.org/file_download.php?file_id=19514&type=bug Examples: http://bugs.freepascal.org/file_download.php?file_id=19513&type=bug Bugtracker: http://bugs.freepascal.org/view.php?id=25607 Now to workaround this I must have more than ~50 needless constructors in Generics.*... and few hundred (!) needless methods in other libraries. Should I live with this? Is there a chance that someone besides me considers this as a bug?

You mean somebody considers it as a bug *and* fixes it ;)?

Reply by email

hinst
to Maciej Izak

27.01.2014, 11:30, "Maciej Izak" :

Show quoted text 12 lines
2014-01-26 Florian Klämpfl > You mean somebody considers it as a bug *and* fixes it ;)? It would be best :). If no one want fix, maybe I will do patch later (in my TODO list is much better Generics.* and patch for Lazarus...). But what is the point of doing a patch if only I recognize this as a bug? Regards, HNB , _______________________________________________ fpc-devel maillist  -   http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

I suggest a modification to your example:
Please observe this: http://pastebin.com/9axN51QE
If you declare a base class with "reintroduced" constructor (like I suggest) then you may prevent FreePascal compiler from "seeing" TObject.Create constructor. Therefore it will determine which constructor to call; so you won't get a compiler error in this example. I think that the fact that it can not determine which constructor to call when TObject.Create overloaded constructor is in scope is just logical; it should work this way. However if Delphi compiler uses a different kind of logic here then perhaps we can call it a bug; but only for Delphi mode; while ObjFPC mode should be left unchanged considering this particular problem.

Reply by email

Maciej Izak
to hinst
Show quoted text 13 lines
I suggest a modification to your example: Please observe this: http://pastebin.com/9axN51QE If you declare a base class with "reintroduced" constructor (like I suggest) then you may prevent FreePascal compiler from "seeing" TObject.Create constructor. Therefore it will determine which constructor to call; so you won't get a compiler error in this example. I think that the fact that it can not determine which constructor to call when TObject.Create overloaded constructor is in scope is just logical; it should work this way. However if Delphi compiler uses a different kind of logic here then perhaps we can call it a bug; but only for Delphi mode; while ObjFPC mode should be left unchanged considering this particular problem.

The main problem is:

1. The error is not only about constructors

2. Reintroduce does not solve the problem

3. TObject.Create, shouldn't be visible in any way from TB (where is visible - and this is a bug. Is visible, but you can call it in any way) and TA level. Sadly when we calling the constructor for TB, TObject.Create is still visible (only when there exist default value for parameter in TA)
- but sould be hidden for ever at TA leve, for any TA child. Following by current logic, this example should not compile:

------begin code------
TA = class
  procedure Foo;
end;
TB = class(TA)
  procedure Foo(A: Integer = 0); overload;
end;
var
  b: TB;
begin
  b := TB.Create;
  b.Foo; // should raise Error: Can't determine which overloaded function
to call
end;
------end code------

I want use ObjFPC too :) I see any single reson to don't fixing this... No side effects.

Returning to the example from bugtracker (
http://bugs.freepascal.org/view.php?id=25607):
FPC don't recognize at TB level that the TObject.Create was hidden on the TA level by

constructor Create(A: Integer = 0); virtual; overload;

Regards,
HNB

Reply by email

Hans-Peter Diettrich
to Maciej Izak
Show quoted text 19 lines
Following by current logic, this example should not compile: ------begin code------ TA = class procedure Foo; end; TB = class(TA) procedure Foo(A: Integer = 0); overload; end; var b: TB; begin b := TB.Create; b.Foo; // should raise Error: Can't determine which overloaded function to call end; ------end code------

Delphi (XE) has no problem with this code, even if TA.Foo also is declared "overload", or both are declared Foo(). The static type (b:TB) determines which static method to call.

Show quoted text 6 lines
Returning to the example from bugtracker (http://bugs.freepascal.org/view.php?id=25607): FPC don't recognize at TB level that the TObject.Create was hidden on the TA level by constructor Create(A: Integer = 0); virtual; overload;
Delphi here requires
  constructor Create(A: Integer = 0); overload; virtual;

Delphi seems to search for overloaded methods only in the same class. Otherwise an error "Previous declaration ... not marked 'overload'" would occur since TObject.Create was not marked 'overload'. Tested with declarations in the same class:

   constructor Create;
   constructor Create(A: integer);

where *both* must be marked 'overload'.

Only if there is no matching method in a class, the ancestors are searched as well. I.e. Delphi does not *hide* inherited methods, it only extends the search into ancestors *when required*, regardless of 'overload' directives.

DoDi

Reply by email