Quantcast
Channel: Delphi – The Wiert Corner – irregular stream of stuff
Viewing all articles
Browse latest Browse all 1440

Porting old code: Delphi compiler error E2064 Left side cannot be assigned to

$
0
0

Quoting this in full because it nicely illustrated the introduction of an intermediate variable that cannot be assigned to a second time after initial setup by the with statement: [WayBack] Embarcadero Newsgroup Archive :: embarcadero.public.delphi.ide :: Re: Delphi 2010 Compile error E2064 Left side cannot be assigned to.

Subject: Re: Delphi 2010 Compile error E2064 Left side cannot be assigned to
Posted by: Uwe Schuster (jediv…@bitcommander.de)
Date: Sat, 10 Oct 2009

Finn Tolderlund wrote:

> I get this error in Delphi 2010 with the code below:
> But if I remove the () from the line, it compiles and executes ok.
> Is it a bug in the compiler?
> …
with (Pal.palPalEntry[i]) do  // Compile error: E2064 Left side cannot be assigned to
with Pal.palPalEntry[i] do  // Works fine

This is no bug, because the parenthesis generates an intermediate
non-addressable value and D2010 does not longer allow write access to intermediate values with “with”.


Uwe

This also might explain Delphi 10.2 Tokyo introduced a “with” warning: for most “with” statements, W1048 is raised ([RSP-17326] with statements generate W1048 unsafe typecast warning – Embarcadero Technologies), assuming that the intermediate is a pointer variable.

–jeroen


Viewing all articles
Browse latest Browse all 1440

Trending Articles