The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,732 other followers

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

Posted by jpluimers on 2021/05/27

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…
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”.


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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: