[fpc-devel] [] property overloads

Ondrej Pokorny lazarus at kluug.net
Tue Jul 2 09:20:08 CEST 2019


On 02.07.2019 09:10, Michael Van Canneyt wrote:
> I had a quick peek in the compiler sources.
>
> In pexpr.pas, before processing the [, the compiler calls this:
>
>         { we need the resultdef }
>         do_typecheckpass_changed(p1,nodechanged);
>
> In my opinion, this routine will/should error out if there are 2 symbols
> called 'StringArray' : one with type 'array property' and one with 
> type 'enumerator'.

This code is never executed for an array property. The "[" for an array 
property is processed directly in handle_propertysym:

     procedure handle_propertysym(propsym : tpropertysym;st : 
TSymtable;var p1 : tnode);
       var
          paras : tnode;
          p2    : tnode;
          membercall : boolean;
          callflags  : tcallnodeflags;
          propaccesslist : tpropaccesslist;
          sym: tsym;
       begin
          { property parameters? read them only if the property really }
          { has parameters                                             }
          paras:=nil;
          if (ppo_hasparameters in propsym.propoptions) then
            begin
              if try_to_consume(_LECKKLAMMER) then
                begin
                  paras:=parse_paras(false,false,_RECKKLAMMER);
                  consume(_RECKKLAMMER);
                end;
            end;

These 3 lines are crucial:

          if (ppo_hasparameters in propsym.propoptions) then
            begin
              if try_to_consume(_LECKKLAMMER) then


Ondrej



More information about the fpc-devel mailing list