diff --git a/.gitattributes b/.gitattributes index 5c5387db5a..6a4d60c263 100644 --- a/.gitattributes +++ b/.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 diff --git a/compiler/pdecsub.pas b/compiler/pdecsub.pas index 3875a9e853..02932fc2bb 100644 --- a/compiler/pdecsub.pas +++ b/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); diff --git a/compiler/psub.pas b/compiler/psub.pas index 9205f2fc56..1e001569cb 100644 --- a/compiler/psub.pas +++ b/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); diff --git a/tests/webtbf/tw7752.pp b/tests/webtbf/tw7752.pp new file mode 100755 index 0000000000..50a2a04a4b --- /dev/null +++ b/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.