My understanding:
Canvas.Textstyle returns a Record, NOT a Object.
If a function's return value is a Record, FPC returns a COPY of the original one, i.e. a copy of Canvas.FTextStyle in this case, Not a reference to the Canvas.FTextStyle itself.
So if we write:
with Canvas.TextStyle do Alignment := taRightJustify;
It equals to:
tmp := Canvas.TextStyle;
tmp.Alignment := taRightJustify;
That's meaningless, and apparently NOT what we want. So, it's reasonable that FPC forbids this behavior.
It can also explains someone reported that the assignment has no effect with lower version of FPC, although allowed.
But that's not the case here:
* first, because there's no "function": it's accessing a field directly;
* second, because it's not a read-only property; and
* third, because using "
with" effectively changes that field, as demonstrated in
my test aboveThe bug is not that it can't be changed but that it
gets changed when using a
with construction.