View Issue Details

IDProjectCategoryView StatusLast Update
0035670FPCCompilerpublic2019-07-05 19:16
ReporterRyan JosephAssigned ToSven Barth 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.3.1Product Build 
Target VersionFixed in Version3.3.1 
Summary0035670: Generic procedure/normal procedure order of declaration error
DescriptionIf you declare a generic procedure followed by an overloaded normal procedure the compiler gives an error. Reversing the order (e.g. normal followed by generic) does not give an error.
Steps To Reproducegeneric procedure DoThis<T>(msg: T);
begin
end;

procedure DoThis(msg: TObject); // <<<----- ERROR: Overloaded identifier "DoThis" isn't a function
begin
end;
Tagsgenerics
Fixed in Revision42329
FPCOldBugId
FPCTarget-
Attached Files

Activities

Ryan Joseph

2019-06-03 01:24

reporter   ~0116542

The problem is in parse_proc_head due to srsym being a ttypsym since the dummy type was registered first. Do we need a way to search for symbols that ignores dummy syms? Right now it's just hash table look up " srsym:=tsym(symtablestack.top.Find(sp));" but maybe there's another function somewhere which does this smarter.

==========================================

                 srsym:=tsym(symtablestack.top.Find(sp));

                 { Also look in the globalsymtable if we didn't found
                   the symbol in the localsymtable }
                 if not assigned(srsym) and
                    not(parse_only) and
                    (symtablestack.top=current_module.localsymtable) and
                    assigned(current_module.globalsymtable) then
                   srsym:=tsym(current_module.globalsymtable.Find(sp));

                 { Check if overloaded is a procsym }
                 if assigned(srsym) then
                   begin
                     if srsym.typ=procsym then
                       aprocsym:=tprocsym(srsym)
                     else
                       begin
                         { when the other symbol is a unit symbol then hide the unit
                           symbol, this is not supported in tp7 }
                         if not(m_tp7 in current_settings.modeswitches) and
                            (srsym.typ=unitsym) then
                          begin
                            HideSym(srsym);
                            searchagain:=true;
                          end
                         else
                         if (m_delphi in current_settings.modeswitches) and
                            (srsym.typ=absolutevarsym) and
                            ([vo_is_funcret,vo_is_result]*tabstractvarsym(srsym).varoptions=[vo_is_funcret]) then
                           begin
                             HideSym(srsym);
                             searchagain:=true;
                           end
                         else
                          begin
                            { we use a different error message for tp7 so it looks more compatible }
                            if (m_fpc in current_settings.modeswitches) then
                              Message1(parser_e_overloaded_no_procedure,srsym.realname)
                            else
                              Message1(sym_e_duplicate_id,srsym.realname);
                            { rename the name to an unique name to avoid an
                              error when inserting the symbol in the symtable }
                            orgsp:=orgsp+'$'+tostr(current_filepos.line);
                          end;
                       end;

Sven Barth

2019-07-05 16:14

manager   ~0117086

The dummy symbol is only required to find the symbol name without any generic brackets. In this case we can simply hide it and continue as usual.

Please test and close if okay.

Ryan Joseph

2019-07-05 19:16

reporter   ~0117091

Fixed.

Issue History

Date Modified Username Field Change
2019-06-02 22:48 Ryan Joseph New Issue
2019-06-03 01:24 Ryan Joseph Note Added: 0116542
2019-07-05 14:55 Sven Barth Tag Attached: generics
2019-07-05 15:31 Sven Barth Assigned To => Sven Barth
2019-07-05 15:31 Sven Barth Status new => assigned
2019-07-05 16:14 Sven Barth Status assigned => resolved
2019-07-05 16:14 Sven Barth Resolution open => fixed
2019-07-05 16:14 Sven Barth Fixed in Version => 3.3.1
2019-07-05 16:14 Sven Barth Fixed in Revision => 42329
2019-07-05 16:14 Sven Barth FPCTarget => -
2019-07-05 16:14 Sven Barth Note Added: 0117086
2019-07-05 19:16 Ryan Joseph Status resolved => closed
2019-07-05 19:16 Ryan Joseph Note Added: 0117091