cdew / dwscript

Automatically exported from code.google.com/p/dwscript
0 stars 0 forks source link

Can't assign to record members in helper #447

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When you try to assign to a member of a record in a record helper, it throws a 
"cannot assign a value to the left-side argument" compiler error.

Here's a script to reproduce:

type
  TTest = record      
    A: Integer;
  end;

type  
  TTestHelper = record helper for TTest
     procedure SetA(NewA: Integer);
  end;

procedure TTestHelper.SetA(NewA: Integer);
begin
   Self.A := NewA;
end;

Original issue reported on code.google.com by frederic...@gmail.com on 7 Nov 2013 at 9:47

GoogleCodeExporter commented 9 years ago
This is a current limitation pending a decision on mutability and helpers.
Currently helper's implicit Self parameter is a "const".

For more details see
http://www.delphitools.info/2012/05/07/mutant-records-on-methods-and-helpers/

Original comment by zar...@gmail.com on 8 Nov 2013 at 2:35