[Lazarus] Bug in cody. Exploding a hanging with block.

Mattias Gaertner nc-gaertnma at netcologne.de
Tue Jun 10 12:57:40 CEST 2014


On Tue, 10 Jun 2014 01:42:54 +0200
Mattias Gaertner <nc-gaertnma at netcologne.de> wrote:

> On Tue, 10 Jun 2014 01:08:49 +0300
> ListMember <listmember at letterboxes.org> wrote:
> 
> >[...]
> > > Changing the $ELSE part is dangerous, because the context is wrong.
> > > The parser does not parse structures within $ELSE parts (e.g. with).
> > > It should warn the user to check carefully those parts.
> > 
> > Warnings would, of course, be useful.
> > 
> > But, for a complex block it will not really help.
> > 
> > This is an example of what I mean:
> > 
> > with something do begin
> > {$IFDEF FAVORITE_OS}
> > {a lot of lines}
> > with somethingelse do begin
> >          {a lot of lines}
> >        end;
> >      {a lot of lines}
> >    {$ELSE}
> > {a lot of lines}
> > with somethingelse do begin
> >          {a lot of lines}
> >        end;
> >      {a lot of lines}
> >    {$ENDIF}
> > end;
> 
> Yes, that's a good example. somethingelse can depend on the OS. You
> need the context to do it right.
> 
>  
> >[...]
> > How about shifting a copy of the 'with' line to inside these IFDEF's, 
> > such as:
> > 
> > {$IFDEF FAVORITE_OS}
> > {code which 'with's have been exploded.}
> >    {$ELSE}
> > with something do begin
> > {a lot of lines}
> > with somethingelse do begin
> >            {a lot of lines}
> >          end;
> >        {a lot of lines}
> >      end;
> >    {$ENDIF}
> > 
> > IOW, when the time comes for the ELSE part, all the information is there 
> > and it compiles even without exploding the 'with's.
> 
> Good idea. It is not always correct, but it would be better than
> nothing (the current solution).

I implemented that.

Mattias




More information about the Lazarus mailing list