problem with calling virtual methods? lazarus / 76-Pas2JS ---------------------------------------------------------------------- mr-highball · 2020-08-22 20:42 pas2js source used is latest trunk pulled 8/22/2020 Trying to implement some classes with pas2js and am noticing an issue with virtual methods. my example is parent class defined with a virtual method with no implementation 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 TNyxElementBaseImpl...//declarationprocedure DoUpdateHeight; virtual; ...//implementationprocedure TNyxElementBaseImpl.DoUpdateHeight;begin  //nothing in baseend  this parent class, makes a call to the virtual method in this other method, 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 TNyxElementBaseImpl.NotifyHeight(const AType: TPropertyUpdateType;  const ASize: INyxSize; const AProperty: TSizeProperty);begin  if AType = puAfterUpdate then    DoUpdateHeight; //  <---------right hereend; now, I have a child class which overrides the DoUpdateHeight method here 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 TNyxElementBrowserImpl = class(TNyxElementBaseImpl, INyxElementBrowser)...//interfaceprocedure DoUpdateHeight; override;...//implprocedure TNyxElementBrowserImpl.DoUpdateHeight;begin  inherited DoUpdateHeight; // <------- we never get here in the debugger  UpdateSize;end; What should be happening is the TNyxElementBrowserImpl.DoUpdateHeight should be used, not the parent's empty stubbed method... but when debugging, the parent method is triggered rather than the overridden child. Has anyone run into this or spot something that I may be doing improperly? any help would be appreciated. for reference, the full source for the examples are found at these lines, parent: https://github.com/mr-highball/nyx/blob/master/src/nyx.types.pas#L262 https://github.com/mr-highball/nyx/blob/master/src/nyx.types.pas#L1726 child: https://github.com/mr- highball/nyx/blob/master/src/nyx.element.browser.pas#L72 https://github.com/mr- highball/nyx/blob/master/src/nyx.element.browser.pas#L149 ---------------------------------------------------------------------- Ñuño_Martínez · 2020-08-23 09:52 It shouldn't be, but did you tried to add SELF. to the calls?  Maybe the transpiler is forgetting to add this. to it and it may mess up the thing (never used pas2js though). BTW, this is to push up this message so more people read it. ---------------------------------------------------------------------- mr-highball · 2020-08-23 19:20 thanks for replying (and for the "bump") @Ñuño_Martínez, I hadn't thought of trying that, but making the change to Self.DoUpdateHeight still seems to be calling the parent stub method rather than the overridden one ---------------------------------------------------------------------- mr-highball · 2020-08-23 20:10 I created this issue in mantis with a test scenario project... but tbh I couldn't break it in the same way that I'm seeing, and have no idea what to try next, just posting this for transparency (and the chance someone spots something I'm not) https://bugs.freepascal.org/view.php?id=37633 ---------------------------------------------------------------------- Ñuño_Martínez · 2020-08-24 09:38 Are you sure you're creating the object with the correct class?  That question seems silly but it is a quite common mistake (I did it no long ago ). ---------------------------------------------------------------------- mr-highball · 2020-08-24 13:35 Yeah, to make sure I did a WriteLn of the classname and it indeed was the child class, but the parent method is being usee (very weird to try and track down) ---------------------------------------------------------------------- Ñuño_Martínez · 2020-08-25 12:15 Quite weird. Anyway, I had similar bugs and most times the problem was that I committed a very silly mistake, so silly it is hidden in front of you. Let's hope somebody can help.