Explorar o código

* fix for Mantis #36223: when parsing a helper type its extendeddef might be Nil
+ added test

git-svn-id: trunk@43346 -

svenbarth %!s(int64=5) %!d(string=hai) anos
pai
achega
fdeaacac21
Modificáronse 3 ficheiros con 30 adicións e 2 borrados
  1. 1 0
      .gitattributes
  2. 11 2
      compiler/symtable.pas
  3. 18 0
      tests/webtbf/tw36223.pp

+ 1 - 0
.gitattributes

@@ -16071,6 +16071,7 @@ tests/webtbf/tw3583.pp svneol=native#text/plain
 tests/webtbf/tw35866.pp svneol=native#text/pascal
 tests/webtbf/tw35981.pp svneol=native#text/pascal
 tests/webtbf/tw36114.pp svneol=native#text/pascal
+tests/webtbf/tw36223.pp svneol=native#text/pascal
 tests/webtbf/tw3626.pp svneol=native#text/plain
 tests/webtbf/tw3631.pp svneol=native#text/plain
 tests/webtbf/tw3643.pp svneol=native#text/plain

+ 11 - 2
compiler/symtable.pas

@@ -3916,8 +3916,17 @@ implementation
               exit;
           end;
         { now search all helpers using the extendeddef as the starting point }
-        if m_multi_helpers in current_settings.modeswitches then
-          result:=search_best_objectpascal_helper(s,classh.extendeddef,contextclassh,srsym,srsymtable);
+        if (m_multi_helpers in current_settings.modeswitches) and
+            (
+              (current_structdef<>classh) or
+              assigned(classh.extendeddef)
+            ) then
+          begin
+            { this is only allowed if classh is currently parsed }
+            if not assigned(classh.extendeddef) then
+              internalerror(2019110101);
+            result:=search_best_objectpascal_helper(s,classh.extendeddef,contextclassh,srsym,srsymtable);
+          end;
       end;
 
     function search_specific_assignment_operator(assignment_type:ttoken;from_def,to_def:Tdef):Tprocdef;

+ 18 - 0
tests/webtbf/tw36223.pp

@@ -0,0 +1,18 @@
+{ %FAIL }
+
+{$mode objfpc}
+{$modeswitch multihelpers}
+
+unit tw36223;
+interface
+uses
+  SysUtils;
+
+type
+  // ERROR: Compilation raised exception internally
+  TMyHelper = class helper for TSomeObject
+  end;
+
+implementation
+
+end.