TFPGList specialization error lazarus / 64-FPC development ---------------------------------------------------------------------- alpine · 2022-08-25 09:10 The following program gives an error on compile: 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 {$mode ObjFPC}{$H+} uses fgl; type  complex = record    re : real;    im : real;  end;   TComplexList = specialize TFPGList;   operator = (z1, z2 : complex) b : boolean;  begin    b := (z1.re=z2.re) and (z1.im=z2.im);  end; beginend.The error is Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fgl.pp(988,50) Error: Operator is not overloaded: "complex" = "complex"What I'm doing wrong? Lazarus 2.2.2 (rev lazarus_2_2_2) FPC 3.2.2 i386-win32-win32/win64 ---------------------------------------------------------------------- simone · 2022-08-25 09:40 Here you can find the explanation of the problem and its solution: https://forum.lazarus.freepascal.org/index.php/topic,46408.msg330800.h tml#msg330800 Your code works if you change it as follows: 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 {$mode ObjFPC}{$H+}{$MODESWITCH ADVANCEDRECORDS} uses  fgl; type  complex = record    re : real;    im : real;    class operator =(const z1, z2: complex): Boolean;  end;   TComplexList = specialize TFPGList;   class operator complex.=(const z1, z2: complex) :  Boolean;  begin    Result := (z1.re=z2.re) and (z1.im=z2.im);  end; beginend. ---------------------------------------------------------------------- alpine · 2022-08-25 10:06 I see. I had to dig deeper, though. Thanks! ---------------------------------------------------------------------- PascalDragon · 2022-08-25 11:25 Quote from: y.ivanov on August 25, 2022, 11:10:05 amWhat I'm doing wrong? Generics can only access global operator overloads that are accessible at the time the generic itself is declared, not when the generic is specialized. So as simone suggested, use type local operator overloads to solve this.