property behaves different if it has a getter

Original Reporter info from Mantis: Martin @martin_frb
  • Reporter name: Martin Friebe

Description:

Afaik properties are meant to abstract if they have a getter or direct field access. They should behave the same. (This was all pointed out, whet none-getter properties had to stop working in "inc()")

In the below code, the properties only differ in having a getter or direct field access. Yet one compiles if address taken, the other not.

Additional information:

program Project1;
{$mode objfpc}{$H+}
uses  Classes;
type
  TFoo = class
  private
    FBar2: integer;
    function GetBar1: integer;
  public
    property Bar1: integer read GetBar1;
    property Bar2: integer read FBar2;
  end;

var
  foo:TFoo;
  b: ^integer;

function TFoo.GetBar1: integer;
begin
   b := @Bar1; // does not compile
   b := @Bar2; // compiles
end;

begin
end.

Mantis conversion info:

  • Mantis ID: 30017
  • OS: win
  • OS Build: vista
  • Platform: w32
  • Version: 3.0.0