<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Martin Frb via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>> schrieb am So., 4. Juni 2023, 18:10:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 04/06/2023 17:49, Martin via fpc-pascal wrote:<br>
> On 04/06/2023 15:04, Juha Manninen via fpc-pascal wrote:<br>
>> Why the following code fails to compile?<br>
>> MyObj.RecInstance.ii := 123;<br>
> Technically you can modify the members of the temp record (just to <br>
> have the work thrown away afterwards).<br>
><br>
> So I guess the compiler forbids it, because the only case it would <br>
> ever be done is: by mistake.<br>
<br>
Btw, this works (or actually not, it works wrong)<br>
<br>
   with  MyObj.RecInstance do {begin} ii := 123; {end;}<br>
<br>
Now you could do some work with the temp result, and have it trashed at <br>
the end of the "with" block.<br>
<br>
However, fpc incorrectly changes the value in the original record.<br>
Yet, don't use it. It will (likely) change, and stop working. (or work <br>
correctly, changing the temp value only).<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Correct. This *will* be fixed also. There already is a bug report about it. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>