Martin Frb via fpc-pascal <fpc-pascal@lists.freepascal.org> schrieb am So.,
4. Juni 2023, 18:10:

> On 04/06/2023 17:49, Martin via fpc-pascal wrote:
> > On 04/06/2023 15:04, Juha Manninen via fpc-pascal wrote:
> >> Why the following code fails to compile?
> >> MyObj.RecInstance.ii := 123;
> > Technically you can modify the members of the temp record (just to
> > have the work thrown away afterwards).
> >
> > So I guess the compiler forbids it, because the only case it would
> > ever be done is: by mistake.
>
> Btw, this works (or actually not, it works wrong)
>
>    with  MyObj.RecInstance do {begin} ii := 123; {end;}
>
> Now you could do some work with the temp result, and have it trashed at
> the end of the "with" block.
>
> However, fpc incorrectly changes the value in the original record.
> Yet, don't use it. It will (likely) change, and stop working. (or work
> correctly, changing the temp value only).
>

Correct. This *will* be fixed also. There already is a bug report about it.

Regards,
Sven

>
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to