Browse Source

* bug #294 fixed: parameters can have now the same name as the function/
procedure, this is compatible with TP/Delphi

florian 25 years ago
parent
commit
2805167e6e
1 changed files with 25 additions and 12 deletions
  1. 25 12
      compiler/symtable.pas

+ 25 - 12
compiler/symtable.pas

@@ -1788,7 +1788,10 @@ implementation
                 (next^.symtabletype=parasymtable) then
                 (next^.symtabletype=parasymtable) then
                 begin
                 begin
                    hsym:=next^.search(sym^.name);
                    hsym:=next^.search(sym^.name);
-                   if assigned(hsym) then
+                   { a parameter and the function can have the same }
+                   { name in TP and Delphi                          }
+                   if assigned(hsym) and
+                     (sym^.typ<>funcretsym) then
                      DuplicateSym(hsym);
                      DuplicateSym(hsym);
                 end
                 end
               else if (current_module^.flags and uf_local_browser)=0 then
               else if (current_module^.flags and uf_local_browser)=0 then
@@ -1804,11 +1807,17 @@ implementation
            (next^.next^.symtabletype=objectsymtable) then
            (next^.next^.symtabletype=objectsymtable) then
            begin
            begin
               hsym:=search_class_member(pobjectdef(next^.next^.defowner),sym^.name);
               hsym:=search_class_member(pobjectdef(next^.next^.defowner),sym^.name);
-              { but private ids can be reused }
               if assigned(hsym) and
               if assigned(hsym) and
+                { private ids can be reused }
                 (not(sp_private in hsym^.symoptions) or
                 (not(sp_private in hsym^.symoptions) or
                  (hsym^.owner^.defowner^.owner^.symtabletype<>unitsymtable)) then
                  (hsym^.owner^.defowner^.owner^.symtabletype<>unitsymtable)) then
-                DuplicateSym(hsym);
+                begin
+                   { delphi allows to reuse the names of properties }
+                   { in procedures                                  }
+                   if not((hsym^.typ=propertysym) and
+                     (m_delphi in aktmodeswitches)) then
+                     DuplicateSym(hsym);
+                end;
            end;
            end;
          { check for duplicate id in para symtable of methods }
          { check for duplicate id in para symtable of methods }
          if (symtabletype=parasymtable) and
          if (symtabletype=parasymtable) and
@@ -1823,16 +1832,16 @@ implementation
            begin
            begin
               hsym:=search_class_member(procinfo^._class,sym^.name);
               hsym:=search_class_member(procinfo^._class,sym^.name);
               if assigned(hsym) and
               if assigned(hsym) and
-                { delphi allows to reuse the names of properties }
-                { in parameter lists of methods                  }
-                not(
-                 (hsym^.typ<>propertysym) or
-                 (m_delphi in aktmodeswitches)
-                ) and
-                { also private ids can be reused }
+                { private ids can be reused }
                 (not(sp_private in hsym^.symoptions) or
                 (not(sp_private in hsym^.symoptions) or
                  (hsym^.owner^.defowner^.owner^.symtabletype<>unitsymtable)) then
                  (hsym^.owner^.defowner^.owner^.symtabletype<>unitsymtable)) then
-                 DuplicateSym(hsym);
+                begin
+                   { delphi allows to reuse the names of properties }
+                   { in parameter lists of methods                  }
+                   if not((hsym^.typ=propertysym) and
+                     (m_delphi in aktmodeswitches)) then
+                     DuplicateSym(hsym);
+                end;
            end;
            end;
          { check for duplicate field id in inherited classes }
          { check for duplicate field id in inherited classes }
          if (sym^.typ=varsym) and
          if (sym^.typ=varsym) and
@@ -2799,7 +2808,11 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.81  2000-03-20 09:34:33  florian
+  Revision 1.82  2000-03-22 09:25:57  florian
+    * bug 294 fixed: parameters can have now the same name as the function/
+      procedure, this is compatible with TP/Delphi
+
+  Revision 1.81  2000/03/20 09:34:33  florian
     * in delphi mode: method parameters can now have the same name as parameters
     * in delphi mode: method parameters can now have the same name as parameters
 
 
   Revision 1.80  2000/03/01 13:56:31  pierre
   Revision 1.80  2000/03/01 13:56:31  pierre