Forráskód Böngészése

- remove internal error 20231102 and the associated define SKIP_INTERNAL20231102 as I've now found an example that would trigger the internal error, but shouldn't fail
+ added test

Sven/Sarah Barth 1 napja
szülő
commit
4bf58bb2d0
5 módosított fájl, 70 hozzáadás és 15 törlés
  1. 10 15
      compiler/pgenutil.pas
  2. 23 0
      tests/tbs/tb0724.pp
  3. 17 0
      tests/tbs/ub0724a.pp
  4. 10 0
      tests/tbs/ub0724b.pp
  5. 10 0
      tests/tbs/ub0724c.pp

+ 10 - 15
compiler/pgenutil.pas

@@ -2823,23 +2823,18 @@ uses
               that we specialize a generic in a different unit that was used
               in the implementation section of the generic's unit and were the
               interface is still being parsed and thus the localsymtable is in
-              reality the global symtable }
+              reality the global symtable
+
+              In addition to that it can also be the case that neither the
+              global- nor the localsymtable is set, namely when the compiler
+              didn't yet have the chance to process on of the units in the
+              (implementation) uses clause simply due to the orders, so don't
+              add anything of that unit yet (once routine bodies need to be
+              specialized everything needed should be in place however). }
             if pu.u.in_interface then
               begin
-                {
-                  MVC: The case where localsymtable is also nil can appear in complex cases and still produce valid code.
-                  In order to allow people in this case to continue, SKIP_INTERNAL20231102 can be defined.
-                  Default behaviour is to raise an internal error.
-                  See also
-                  https://gitlab.com/freepascal.org/fpc/source/-/issues/40502
-                }
-                {$IFDEF SKIP_INTERNAL20231102}
-                if (pu.u.localsymtable<>Nil) then
-                {$ELSE}
-                if (pu.u.localsymtable=Nil) then
-                  internalerror(20231102);
-                {$ENDIF}
-                  symtablestack.push(pu.u.localsymtable);
+                if assigned(pu.u.localsymtable) then
+                  symtablestack.push(pu.u.localsymtable)
               end
             else
               internalerror(200705153)

+ 23 - 0
tests/tbs/tb0724.pp

@@ -0,0 +1,23 @@
+unit tb0724;
+
+{$mode delphi}{$H+}
+
+interface
+
+type
+  ITest<T> = interface
+  end;
+
+implementation
+
+uses
+  { when the compiler reaches ucycleb then depending on the order either ub0724b
+    or ub0724c will have neither its global- nor localsymtable set when the
+    compiler specializes ITest<>, because the compiler didn't yet reach the
+    point to compile either ucyclec or ucycled }
+  ub0724b,
+  ub0724a,
+  ub0724c;
+
+end.
+

+ 17 - 0
tests/tbs/ub0724a.pp

@@ -0,0 +1,17 @@
+unit ub0724a;
+
+{$mode delphi}{$H+}
+
+interface
+
+uses
+  tb0724;
+
+type
+  TTest = class(TInterfacedObject, ITest<TObject>)
+  end;
+
+implementation
+
+end.
+

+ 10 - 0
tests/tbs/ub0724b.pp

@@ -0,0 +1,10 @@
+unit ub0724b;
+
+{$mode objfpc}{$H+}
+
+interface
+
+implementation
+
+end.
+

+ 10 - 0
tests/tbs/ub0724c.pp

@@ -0,0 +1,10 @@
+unit ub0724c;
+
+{$mode objfpc}{$H+}
+
+interface
+
+implementation
+
+end.
+