Generic type nil problem lazarus / 62-General ---------------------------------------------------------------------- J-23 · 2020-09-29 22:39 Hello, I wanted to present some code that shows some inconsistency in specifying type in generic classes. Maybe it is worth considering improving this in the next FPC versions, but before I can report it, I wanted to know the opinions, hence the publication on the forum. Having the code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type   { TBaseWizardDialogEditorClass }   generic TBaseWizardDialogEditorClass = class(TObject)  private    FOnActionClose: TCloseEvent;    FOnMasterDataSetField: TOnMasterDataSetField;    procedure SetOnActionClose(AValue: TCloseEvent);    procedure SetOnMasterDataSetField(AValue: TOnMasterDataSetField);  protected    FFormWizard: F;    procedure DoActionButton(Sender: TObject); virtual; abstract;    procedure EditObject(EditObject: T); virtual; abstract;  public    destructor Destroy; override;    procedure Show; virtual;    procedure Clear; virtual; abstract;    procedure DefaultValueComponent; virtual; abstract;    procedure DefaultValueComponent(DataSetValue: string); virtual; abstract;    property OnActionClose: TCloseEvent read FOnActionClose write SetOnActionClose;    property OnMasterDataSetField: TOnMasterDataSetField read FOnMasterDataSetField write SetOnMasterDataSetField;  end; implementation  { TBaseEditorClass } procedure TBaseEditorClass.DoActionClose(Sender: TObject;  var CloseAction: TCloseAction);begin  FActionTypeEditor := ateAdd;end; procedure TBaseEditorClass.Edit(Item: T);begin  FActionTypeEditor := ateEdit;end; procedure TBaseEditorClass.Show;begin  case FActionTypeEditor of    ateAdd: FWizardEditor.Show;    ateEdit: FWizardEditEditor.Show;  end;end; { TBaseWizardDialogEditorClass } procedure TBaseWizardDialogEditorClass.SetOnActionClose(AValue: TCloseEvent);begin  if FOnActionClose = AValue then Exit;  FOnActionClose := AValue;end; procedure TBaseWizardDialogEditorClass.SetOnMasterDataSetField(  AValue: TOnMasterDataSetField);begin  if FOnMasterDataSetField = AValue then Exit;  FOnMasterDataSetField := AValue;end; destructor TBaseWizardDialogEditorClass.Destroy;begin  if FFormWizard <> nil then    FreeAndNil(FFormWizard);  inherited Destroy;end; procedure TBaseWizardDialogEditorClass.Show;begin  FFormWizard.ShowModal;end; end. Due to the fact that in line 65 there is: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if FFormWizard <> nil then I get the message (during compilation): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i WizardDialogEditorRBM.pas(119,21) Error: Incompatible types: got "Pointer" expected "$gendef1" Which clearly indicates that I do not know if type is a pointer, hence the above message and it would be true if I declared my class like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  generic TBaseWizardDialogEditorClass = class(TObject) but my class declaration specifies the type so the above message shouldn't be. (According to me) What do you think about it? Is it worth reporting it? A few words on this topic https://forum.lazarus.freepascal.org/index.php?topic=42009.0 were mentioned in this thread that it is like Delphi is similar but I do not have how to check it now. Even if it were, there would be no consequences for a notation like Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ---------------------------------------------------------------------- Blaazen · 2020-09-29 23:01 I tried your code with 3.3.1 - yesterday trunk, {$mode objfpc} and I got no error message for both variants, i.e. both: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i generic TBaseWizardDialogEditorClass = class(TObject)andgeneric TBaseWizardDialogEditorClass = class(TObject)compiles well. ---------------------------------------------------------------------- J-23 · 2020-09-29 23:13 Quote from: Blaazen on September 30, 2020, 01:01:50 amI tried your code with 3.3.1 - yesterday trunk, {$mode objfpc} and I got no error message for both variants, i.e. both: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i generic TBaseWizardDialogEditorClass = class(TObject)andgeneric TBaseWizardDialogEditorClass = class(TObject)compiles well. Thanks for the information. I will try ---------------------------------------------------------------------- PascalDragon · 2020-09-30 08:16 Quote from: Blaazen on September 30, 2020, 01:01:50 amI tried your code with 3.3.1 - yesterday trunk, {$mode objfpc} and I got no error message for both variants, i.e. both: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i generic TBaseWizardDialogEditorClass = class(TObject)andgeneric TBaseWizardDialogEditorClass = class(TObject)compiles well. Seems like I'll have to hunt for the revision that fixed that and have that merged to 3.2.1... ---------------------------------------------------------------------- J-23 · 2020-09-30 10:53 I confirm it works. However, there is a new problem with FPC 3.3.1 not compiling FastReport when compiling I am getting a message: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i frxXML.pas(475,22) Error: Asm: signed dword value exceeds bounds -4294967296 It concerns the procedure: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TfrxXMLItem.SetOffset(const Value: Int64);begin  FHiOffset := Value div $100000000;  FLoOffset := Value mod $100000000; //this errorend;  Which will be in the file: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i C:\Program Files (x86)\FastReport 5 VCL Professional\Source\frxXML.pas This problem was not present in the previous FPC version, but there was a problem with the generics I will only add that around the Lazarus 2.0.8 version, the generic code that I presented earlier, Lazarus compiled it How do I get around the problem so that I can install FastReport? ---------------------------------------------------------------------- PascalDragon · 2020-09-30 11:36 Quote from: J-23 on September 30, 2020, 12:53:21 pmHowever, there is a new problem with FPC 3.3.1 not compiling FastReport when compiling I am getting a message: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i frxXML.pas(475,22) Error: Asm: signed dword value exceeds bounds -4294967296 Are you compiling with -al or any -Axxx option? Cause that message comes from the external assembler (though I can not reproduce it with the as I have, at least not with a simple example code). ---------------------------------------------------------------------- J-23 · 2020-09-30 11:51 No, it compiles on standard options. What information do you need to diagnose the problem? ---------------------------------------------------------------------- PascalDragon · 2020-09-30 20:26 As a first step your complete compiler commandline. Cause the error message is from the external assembler as it does not exist in the compiler. ---------------------------------------------------------------------- J-23 · 2020-10-01 00:28 Quote from: PascalDragon on September 30, 2020, 10:26:35 pmAs a first step your complete compiler commandline. Cause the error message is from the external assembler as it does not exist in the compiler. OK, I'll check and give it, or even prepare a virtual machine that shows the problem. I will add that the problem only occurs on 64 bits on 32 bits, everything is ok.