Recent

Author Topic: [SOLVED] Error: Internal error 200305108  (Read 880 times)

EganSolo

  • Sr. Member
  • ****
  • Posts: 334
[SOLVED] Error: Internal error 200305108
« on: June 04, 2025, 12:57:02 am »
Laz 4.0
I've got a relatively simple class
Code: Pascal  [Select][+][-]
  1.   TActionPayload = class
  2.   //Used to carry information for creating todo entries
  3.   public
  4.     constructor Create;
  5.     Procedure Clear;
  6.   private
  7.     fInstance      : String                   ;
  8.     fMsgTemplate   : String                   ;
  9.     fNewInstance   : String                   ;
  10.     fSourceInstance: String                   ;
  11.     fStrID         : String                   ;
  12.     fTable         : enum_Type;
  13.   private
  14.     procedure SetInstance      (const aValue: String   );
  15.     procedure SetMsgTemplate   (const aValue: String   );
  16.     procedure SetNewInstance   (const aValue: String   );
  17.     procedure SetSourceInstance(const aValue: String   );
  18.     procedure SetStrID         (const aValue: String   );
  19.     procedure SetTable         (const aValue: enum_Type);
  20.   public
  21.     Property StrID          : String    read fStrID          write SetStrID         ;
  22.     Property Instance       : String    read fInstance       write SetInstance      ;
  23.     Property NewInstance    : String    read fNewInstance    write SetNewInstance   ;
  24.     Property SourceInstance : String    read fSourceInstance write SetSourceInstance; //used when cloning
  25.     Property Table          : enum_Type read fTable          write SetTable         ;
  26.     Property MsgTemplate    : String    read fMsgTemplate    write SetMsgTemplate   ;
  27.   end;
  28.  

The compiler generates an internal error when it encounters this code:

Code: Pascal  [Select][+][-]
  1. constructor TActionPayload.Create;
  2. begin //Internal Error here
  3.  
  4. end;
  5.  

If I remove the constructor, the code compiles.
The error persists after a clean build (my source code only, not the IDE).
It's not a show-stopper, but it's disconcerting.
« Last Edit: June 04, 2025, 07:18:32 am by EganSolo »

dsiders

  • Hero Member
  • *****
  • Posts: 1453
Re: Error: Internal error 200305108
« Reply #1 on: June 04, 2025, 01:37:08 am »
Laz 4.0
I've got a relatively simple class
Code: Pascal  [Select][+][-]
  1.   TActionPayload = class
  2.   //Used to carry information for creating todo entries
  3.   public
  4.     constructor Create;
  5.     Procedure Clear;
  6.   private
  7.     fInstance      : String                   ;
  8.     fMsgTemplate   : String                   ;
  9.     fNewInstance   : String                   ;
  10.     fSourceInstance: String                   ;
  11.     fStrID         : String                   ;
  12.     fTable         : enum_Type;
  13.   private
  14.     procedure SetInstance      (const aValue: String   );
  15.     procedure SetMsgTemplate   (const aValue: String   );
  16.     procedure SetNewInstance   (const aValue: String   );
  17.     procedure SetSourceInstance(const aValue: String   );
  18.     procedure SetStrID         (const aValue: String   );
  19.     procedure SetTable         (const aValue: enum_Type);
  20.   public
  21.     Property StrID          : String    read fStrID          write SetStrID         ;
  22.     Property Instance       : String    read fInstance       write SetInstance      ;
  23.     Property NewInstance    : String    read fNewInstance    write SetNewInstance   ;
  24.     Property SourceInstance : String    read fSourceInstance write SetSourceInstance; //used when cloning
  25.     Property Table          : enum_Type read fTable          write SetTable         ;
  26.     Property MsgTemplate    : String    read fMsgTemplate    write SetMsgTemplate   ;
  27.   end;
  28.  

The compiler generates an internal error when it encounters this code:

Code: Pascal  [Select][+][-]
  1. constructor TActionPayload.Create;
  2. begin //Internal Error here
  3.  
  4. end;
  5.  

If I remove the constructor, the code compiles.
The error persists after a clean build (my source code only, not the IDE).
It's not a show-stopper, but it's disconcerting.

Your class is implicitly derived from TObject which already has a Create constructor and a NewInstance method. One you need to override. The other you don't want to mess with.

Consult the RTL docs.
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

EganSolo

  • Sr. Member
  • ****
  • Posts: 334
Re: Error: Internal error 200305108
« Reply #2 on: June 04, 2025, 07:18:14 am »
dsiders: Thank you for the tip! I renamed the property NewInstance to NewInstanceVal (alongside the attribute and the setter), and the problem went away.

By the way, when you stated I needed to override the create constructor, you didn't mean it as in override and virtual, did you? As far as I know, the create constructor of TObject is not virtual, is it not?

cdbc

  • Hero Member
  • *****
  • Posts: 2264
    • http://www.cdbc.dk
Re: [SOLVED] Error: Internal error 200305108
« Reply #3 on: June 04, 2025, 07:30:08 am »
Hi
Quote
As far as I know, the create constructor of TObject is not virtual, is it not?
No the constructor in TObject is not virtual, so no 'override' directive necessary there, however you can call 'inherited Create;' in the body of the constructor, just to be nice  ;) (the body of 'TObject.Create' is empty).
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

Thaddy

  • Hero Member
  • *****
  • Posts: 17451
  • Ceterum censeo Trumpum esse delendum (Tnx Charlie)
Re: [SOLVED] Error: Internal error 200305108
« Reply #4 on: June 04, 2025, 08:04:57 am »
https://www.freepascal.org/docs-html/rtl/system/tobject.create.html
The use of the word "currently" indicates that this behavior may change.
Benny is right, but it is even a bit stronger: you MUST call inherited create.
As the manual states, there is hidden code that needs to be executed, even if the create looks empty.
The correct way to handle your own parameterless create is like so:
Code: Pascal  [Select][+][-]
  1. program reint;
  2. {$mode objfpc}
  3. type
  4.   TMyObject = class
  5.   public
  6.     { constructor is not virtual, so use reintroduce }
  7.     constructor create;reintroduce;
  8.   end;
  9.  
  10.   constructor TMyObject.Create;
  11.   begin
  12.     { must call inherited }
  13.     inherited create;
  14.     writeln('My constructor');
  15.   end;
  16.  
  17. var o:TMyObject;
  18. begin
  19.   o:= TMyObject.Create;
  20.   o.free;
  21.   readln;
  22. end.
 
reintroduce suppresses any warnings about the constructor, although in this case it is not strictly necesssary, it is good practice.
« Last Edit: June 04, 2025, 09:13:50 am by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

Fibonacci

  • Hero Member
  • *****
  • Posts: 788
  • Internal Error Hunter
Re: [SOLVED] Error: Internal error 200305108
« Reply #5 on: June 04, 2025, 09:27:01 am »
Reported internal error: #41274

Code: Pascal  [Select][+][-]
  1. type
  2.   tt = class
  3.     ff: byte;
  4.     property NewInstance: byte read ff;
  5.     constructor Create;
  6.   end;
  7.  
  8. constructor tt.Create;
  9. begin // Error: Internal error 200305108
  10. end;
  11.  
  12. begin
  13. end.

PascalDragon

  • Hero Member
  • *****
  • Posts: 6049
  • Compiler Developer
Re: [SOLVED] Error: Internal error 200305108
« Reply #6 on: June 05, 2025, 09:35:09 pm »
Benny is right, but it is even a bit stronger: you MUST call inherited create.
As the manual states, there is hidden code that needs to be executed, even if the create looks empty.

The code that calls NewInstance is part of every constructor. It depends on a hidden parameter whether the code is executed or not (it's not executed for an inherited call or if a constructor is called as an ordinary method). Thus assuming that one knows that TObject.Create is empty, calling the parent constructor is not a must (though of course it's highly suggested).

 

TinyPortal © 2005-2018