Browse Source

* nested procedures are not supported in generic methods

git-svn-id: trunk@7368 -
peter 18 years ago
parent
commit
e7ead9fc9f
4 changed files with 32 additions and 4 deletions
  1. 1 0
      .gitattributes
  2. 2 1
      compiler/pdecsub.pas
  3. 3 3
      compiler/psub.pas
  4. 26 0
      tests/webtbf/tw7752.pp

+ 1 - 0
.gitattributes

@@ -7289,6 +7289,7 @@ tests/webtbf/tw7070.pp svneol=native#text/plain
 tests/webtbf/tw7322.pp svneol=native#text/plain
 tests/webtbf/tw7438.pp svneol=native#text/plain
 tests/webtbf/tw7438a.pp svneol=native#text/plain
+tests/webtbf/tw7752.pp svneol=native#text/plain
 tests/webtbf/tw7989.pp svneol=native#text/plain
 tests/webtbf/tw7998.pp svneol=native#text/plain
 tests/webtbf/tw8019.pp svneol=native#text/plain

+ 2 - 1
compiler/pdecsub.pas

@@ -834,7 +834,8 @@ implementation
         pd.proctypeoption:=potype;
 
         { methods inherit df_generic or df_specialization from the objectdef }
-        if assigned(pd._class) then
+        if assigned(pd._class) and
+           (pd.parast.symtablelevel=normal_function_level) then
           begin
             if (df_generic in pd._class.defoptions) then
               include(pd.defoptions,df_generic);

+ 3 - 3
compiler/psub.pas

@@ -1382,9 +1382,9 @@ implementation
             if (tcgprocinfo(current_procinfo).nestedprocs.count>0) then
               begin
                 if (df_generic in current_procinfo.procdef.defoptions) then
-{$warning TODO Add error message for nested procs in generics}
-                  internalerror(200511151)
-                else if (po_inline in current_procinfo.procdef.procoptions) then
+                  Comment(V_Error,'Generic methods cannot have nested procedures')
+                else
+                 if (po_inline in current_procinfo.procdef.procoptions) then
                   begin
                     Message1(parser_w_not_supported_for_inline,'nested procedures');
                     Message(parser_w_inlining_disabled);

+ 26 - 0
tests/webtbf/tw7752.pp

@@ -0,0 +1,26 @@
+{ %fail }
+
+{$mode objfpc}
+unit tw7752;
+interface
+type generic TMapNode<_Key,_Value> = class(TObject)
+       key: _Key;
+       value: _Value;
+     end;
+     generic TMap<_Key,_Value> = class(TObject)
+     private
+     public
+       procedure Insert(x: TMapNode);
+     end;
+
+implementation
+
+procedure TMap.Insert(x: TMapNode);
+	procedure TreeInsert(z: TMapNode);
+	var x,y: TMapNode;
+	begin
+	end;
+begin
+end;
+
+end.