Recent

Author Topic: class operators overloads with same parameters error, porting delphi code  (Read 485 times)

jamie

  • Hero Member
  • *****
  • Posts: 4058
trying to port a project from D... its not working so well..

I have a Record loaded with class operators and a series of some operators with the same parameters but different result values..

 Fpc 3.2.x rejecting it.
Example

 Class Operator Implicit(const a:TSomeRecord):String;
 class Operator Implicit(const a:TSomeRecord):Integer;
 class Operator Implicit(const a:TSomeRecord):pointer;

 and so on.
 It won't allow the multiple duplicating parms

how do I get around this ? Any hints from the compiler gods ?
The only true wisdom is knowing you know nothing

Blaazen

  • Hero Member
  • *****
  • Posts: 3011
  • POKE 54296,15
    • Eye-Candy Controls
Re: class operators overloads with same parameters error, porting delphi code
« Reply #1 on: November 01, 2020, 01:20:43 am »
It seems to work in 3.3.1 and {$mode delphi}.

But in {$mode objfpc} + {$modeswitch advancedrecords} does not work.
Lazarus 2.1.0 r64115 FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

jamie

  • Hero Member
  • *****
  • Posts: 4058
Re: class operators overloads with same parameters error, porting delphi code
« Reply #2 on: November 01, 2020, 02:00:02 am »
ok, the best I have a the moment is 3.2.0 and I am sure its in Delphi mode..

this kind of puts the breaks on hard with this project then because there is a lot of code that uses overloading via the results type.

 I just did a experiment with variants to see if possibly the compiler would be resetting the expected return type in the return allocator so that I could inspect the return before setting it to a value to determine what to be expected. But that also fails. To bad the compiler didn't have a switch in there for that to preset the desired return type before calling the function.. it would make this a lot easier.

The only true wisdom is knowing you know nothing

PascalDragon

  • Hero Member
  • *****
  • Posts: 2636
  • Compiler Developer
Re: class operators overloads with same parameters error, porting delphi code
« Reply #3 on: November 01, 2020, 05:35:18 pm »
It works correctly in both mode Delphi and mode ObjFPC with both 3.2.0 and 3.3.1. However in mode ObjFPC the operator is named := and not Implicit.

jamie

  • Hero Member
  • *****
  • Posts: 4058
Re: class operators overloads with same parameters error, porting delphi code
« Reply #4 on: November 01, 2020, 09:43:07 pm »
I just tried that in a stand along test app and it works but it does not work in the unit that has a lot of code in it.

the record it lives in also has a lot of operator  handlers in it, going both directions in operation.

seems this is happening on large apps with a lot of code crunching.

 Also this code has a lot of compiler processing macros that is really messing up the works too.

 I can uncomment that area and recompile again to get a display dump of the error report when I get around to it.

The only true wisdom is knowing you know nothing

PascalDragon

  • Hero Member
  • *****
  • Posts: 2636
  • Compiler Developer
Re: class operators overloads with same parameters error, porting delphi code
« Reply #5 on: November 02, 2020, 09:29:46 am »
I just tried that in a stand along test app and it works but it does not work in the unit that has a lot of code in it.

Without some code showing the problem I can't help.

 

TinyPortal © 2005-2018