Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-12

FPC2.6 failed to raise compiler error "Argument can't be assigned to' for Generic class' Record property in "With" clause

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Dennis Poon

I think I found a bug in FPC 2.6.2.
In a method of a derived specialized class, the compiler does not raise error (which it should)
With "record property" do

    "record property's field" := NewValue   //it should raise error

since it is a record property and should not be allowed to modify just one field.

Please see below sample code for reproducing the error:

Dennis

--------------

Type
   RDevice=record
     Value : String;
     UpdatedAt : TDateTime;
   end;
   generic TGData <TData> =class(TComponent)
   private
     FData :  TData;
   public
     property Data : TData read FData;
   end;
   TDevice = class(specialize TGData<RDevice>)
   published
     procedure Test;
   end;
implementation
procedure TDevice.Test;
begin
   With Data do
     Value := ''; //no Compiler Error raised !!!
   Data.Value := ''; //Compiler raised "Error Argument can't be assigned to"
end;
Sven Barth
to Dennis Poon
"Dennis Poon" wrote
I think I found a bug in FPC 2.6.2. In a method of a derived specialized class, the compiler does not raise

error (which it should)

With "record property" do "record property's field" := NewValue //it should raise error since

it is a record property and should not be allowed to modify just one field.

Please see below sample code for reproducing the error:

1. Not related to generics
2. Does not generate an error in trunk either

So, please report a bug.

Regards,
Sven