* * *

Author Topic: Feature Request: Show generic class parameters for Errors with generics  (Read 452 times)

soerensen3

  • Jr. Member
  • **
  • Posts: 77
I'm using generics a lot and one problem I am always facing is one cannot tell which specialization caused an error. I better explain it with some example code:
Code: Pascal  [Select]
  1. type
  2.   generic gTestGeneric < T > = class ( TObject )
  3.     SomeField: T;
  4.     procedure CreateField;
  5.   end;
  6.  
  7. TTestObj1 = class( TObject )
  8.   constructor Create( abc: String );
  9. end;
  10.  
  11. TTestObj2 = class( TObject )
  12.   constructor Craete( abc: String ); // Some typo
  13. end;
  14.  
  15. TTestGeneric1 = specialize gTestGeneric <TTestObj1>;
  16. TTestGeneric2 = specialize gTestGeneric <TTestObj2>;
  17.  
  18. implementation
  19.  
  20. procedure gTestGeneric.CreateField;
  21. begin
  22.   SomeField:= T.Create( 'abc' ); // Error here without telling which specialization caused the problem (In this case TTestObj2)
  23. end;
  24. ...
  25.  
This is only an example to show that sometimes errors are only caused for some specialization and there is no way to tell from the error message which specialization is causing it. Would it be very complicated to implement in the compiler? What do you think?
Lazarus 1.9 with FPC 3.0.4
Target: Manjaro Linux 64 Bit (4.9.68-1-MANJARO)

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus