unexpected added extra functions lazarus / 9-Editor ---------------------------------------------------------------------- Paolo · 2021-08-13 18:11 Dear All, at the moment I am not able to isolate the problem, but it is the second time I see this happening in some application of mine and at the moment it is sistematic. simply adding a design time a button in my application, and generating the sckeleton of "onclick" events, the compiler generates some function duplicates with empty code, the affected routines are the same each time, I know that these are not meaningful information, but any insight on what can be happening is appreciated. just for example, at the begin  I have: 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  TForm1 = class(TForm)  private   public    procedure A(xx...);    procedure B(xx...);  end; var  Form1: TForm1; implementation {$R *.lfm}procedure TForm1.A(xx...);begin  //do somethingend; procedure TForm1.B(xx...);begin  //do somethingend;   after adding a TButton and clicking on object inspector to create the onclick event the code becames, 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   TForm1 = class(TForm)    procedure Button1Click(Sender: TObject);  private   public    procedure A(xx...);    procedure B(xx...);  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.A(xx...); <-- duplicatedbegin  //EMPTYend; procedure TForm1.B(xx...); <-- duplictedbegin  //EMPTYend; procedure TForm1.A(xx...);begin  //do somethingend; procedure TForm1.B(xx...);begin  //do somethingend; procedure TForm1.Button1Click(Sender: TObject);begin end;   then the compiler warning was : "ERROR: overloaded functions have the same parameter list" win-10 64bit, LAZ 2.0.12, fpc 3.2.0 ---------------------------------------------------------------------- Martin_fr · 2021-08-13 18:34 Some general info / this is not my area of expertise.... IIRC the issue has been mentioned before (maybe even a bug reported, not sure / you might want to check). But without exact steps, how to reproduce, it will be hard to track. 1) Does it always happen. Can you freshly load your project, and make it happen at will? Or does it only happen after you worked for a while in the IDE? 2) menu: view > ide internals > view codetool node info. Once it happen immediately get all the info (from all tabs) for the unit in which it happens (the unit must be the active editor when you go to the menu) For all else, someone with experience on the codetools has to look at. ---------------------------------------------------------------------- Martin_fr · 2021-08-13 18:40 My personal guess. Just a very wild guess.... It may be that codetool assumes the end of the file before the existing declaration. It could be that this is related to an issue I observed. Invoking code navigation on a word in a comment sometimes leaves code after the comment unreachable to codetools. Normally however this will give errors, rather that performing a wrong action. In any case, it might be worth to pay attention to any codetool invocation (hint, navigation, completion,...) inside a comment. ---------------------------------------------------------------------- Paolo · 2021-08-13 18:46 thanks Martin, QuoteBut without exact steps, how to reproduce, it will be hard to track. Yes, I know, I have to try to isolate the cause in a smaller project Quote1) Does it always happen. Can you freshly load your project, and make it happen at will? Or does it only happen after you worked for a while in the IDE? Always. Very reproducible. It happens at the any moment I'll try to add a button event (not checked for other components..) Quote 2) menu: view > ide internals > view codetool node info. Once it happen immediately get all the info (from all tabs) for the unit in which it happens (the unit must be the active editor when you go to the menu) I'll check. the form where it happens is the main form and it is the one on which I put the button. Some other info: - project ported from Delphi code - the routines affected have a large amount of parameters in their declaration. ---------------------------------------------------------------------- Martin_fr · 2021-08-13 18:50 If you know it will happen, then also get the "codetool node info" immediately before. ---------------------------------------------------------------------- Paolo · 2021-08-14 06:49 @Martin, attached my "View" menu, sorry it was in Italian language, where is "view > ide internals > view codetool node info" ? ---------------------------------------------------------------------- Paolo · 2021-08-14 17:16 SOLVED ! here how ot reproduce the problem. Look at the code below 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    TForm1 = class(TForm)  private   public    procedure PROC2(ANumX, ANumY: integer; AOffsdB: double;                    var AMaxdB, AMaxDeg : double;                    var AXMax, AYMax : double;                  var AThMax, AFiMax: double);  end; var  Form1: TForm1; implementation {$R *.lfm} procedure TForm1.PROC2(ANumX, ANumY: integer; AOffsdB: double;                       var AMaxdB, AMaxDeg, AXMax, AYMax, AThMax, AFiMax: double);beginend;  It compiles, but... look at the PROC2 declaration "TFrom1.PROC2" where several variables are declared by unique "var", whereas in the first declaration PROC2 has several  "var" used. when add a "TButton" e doubleclick on it to create the click event, the editor is so smart to create the missed declaration with all the "var", and the code becomes as follow 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    TForm1 = class(TForm)    Button2: TButton;    procedure Button2Click(Sender: TObject);  private   public    procedure PROC2(ANumX, ANumY: integer; AOffsdB: double;                    var AMaxdB, AMaxDeg : double;                  var AXMax, AYMax : double;                    var AThMax, AFiMax: double);  end; var  Form1: TForm1; implementation {$R *.lfm} procedure TForm1.PROC2(ANumX, ANumY: integer; AOffsdB: double;                       var AMaxdB, AMaxDeg, AXMax, AYMax, AThMax, AFiMax: double);beginend; procedure TForm1.Button2Click(Sender: TObject);begin end; procedure TForm1.PROC2(ANumX, ANumY: integer; AOffsdB: double; var AMaxdB,  AMaxDeg: double; var AXMax, AYMax: double; var AThMax, AFiMax: double);begin end;  and finally you have two procedures and the "ERROR: overloaded functions have the same parameter listimplemenation". Probably the implementation section was edited-by-hand and the multiple var omitted, but please note that all works fine (and this is conceptually right). However, It should be a bug, either because not exactly equal declaration is implemented in the two sections or because the editor does not recognize that the two declarations are essentially the same (I propend for the first option...). ---------------------------------------------------------------------- Martin_fr · 2021-08-14 17:57 1) Was the existing body generated by codetools from the existing header? Or were they edited by hand, so they looked different? 2) Please report on the bug-tracker. ---------------------------------------------------------------------- Paolo · 2021-08-14 18:33 Quote« Reply #8 on: Today at 07:57:51 pm » Quote 1) Was the existing body generated by codetools from the existing header? Or were they edited by hand, so they looked different? I spose by hand, but later I'll check also the codetool behaviour Quote« Reply #8 on: Today at 07:57:51 pm » Quote 2) Please report on the bug-tracker Ok, I'll check how, it is the first time. However it remain not clear why the editor create the supposed missed procedure body once the tbutton onclick is placed in the code (it should just said "missed procedure body") ---------------------------------------------------------------------- JuhaManninen · 2021-08-14 18:52 Quote from: Martin_fr on August 14, 2021, 07:57:51 pm2) Please report on the bug-tracker. No need to report. It is a knows issue and is already reported. I try to find the issue... This is similar although not exactly the same :  https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/35413 This modifies the implementation signature although the summary says it duplicates.  "Code completion duplicates method implementation"  https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/18793 Is there no report about the duplicated handler? I remember there was. Maybe this example case could be added to #18793. Its summary sounds right. ---------------------------------------------------------------------- Paolo · 2021-08-15 10:27 just one note more. If the code is as below, (where two procedure declarations have different "form", but it complies and works) 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  TForm1 = class(TForm)  private   public    procedure PROC2(ANumX, ANumY: integer; AOffsdB: double;                    var AMaxdB, AMaxDeg : double;                    var AXMax, AYMax : double;                  var AThMax, AFiMax: double);  end; var  Form1: TForm1; implementation {$R *.lfm} procedure TForm1.PROC2(ANumX, ANumY: integer; AOffsdB: double; var AMaxdB,  AMaxDeg, AXMax, AYMax, AThMax, AFiMax: double);begin end;   and ctrl+shift+C si done on the first procedure declaration, no added extra procedure is created, but the second declaration is updated accordingly to the first declaration 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    TForm1 = class(TForm)  private   public    procedure PROC2(ANumX, ANumY: integer; AOffsdB: double;                    var AMaxdB, AMaxDeg : double;                    var AXMax, AYMax : double;                  var AThMax, AFiMax: double);  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.PROC2(ANumX, ANumY: integer; AOffsdB: double; var AMaxdB,  AMaxDeg: double; var AXMax, AYMax: double; var AThMax, AFiMax: double);begin end;