View Issue Details

IDProjectCategoryView StatusLast Update
0035670FPCCompilerpublic2019-07-05 17:16
ReporterRyan Joseph Assigned ToSven Barth  
Status closedResolutionfixed 
Product Version3.3.1 
Fixed 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);

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


Ryan Joseph

2019-06-02 23: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(;" but maybe there's another function somewhere which does this smarter.



                 { Also look in the globalsymtable if we didn't found
                   the symbol in the localsymtable }
                 if not assigned(srsym) and
                    not(parse_only) and
                    ( and
                    assigned(current_module.globalsymtable) then

                 { Check if overloaded is a procsym }
                 if assigned(srsym) then
                     if srsym.typ=procsym then
                         { 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
                         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
                            { we use a different error message for tp7 so it looks more compatible }
                            if (m_fpc in current_settings.modeswitches) then
                            { rename the name to an unique name to avoid an
                              error when inserting the symbol in the symtable }

Sven Barth

2019-07-05 14: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 17:16

reporter   ~0117091


Issue History

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