Why can I have a local variable in a method that out-scopes a class property without a hint or warning?

Why can I have a local variable in a method that out-scopes a class property without a hint or warning?

One thing is allowing name overlaps for method parameters, but for local variables – does that even make sense?

type

  TBadClass = class

  private

    FValue: Integer;

    procedure SetValue(const Value: Integer);

  public

    procedure CheckValue;

    property Value: Integer read FValue write SetValue;

  end;

procedure TBadClass.SetValue(const Value: Integer);

begin

  FValue := Value;

end;

procedure TBadClass.CheckValue;

var

  Value: Integer;

begin

  Value := 1;

  Writeln(‘Value ‘, Value);

  Writeln(‘Self ‘, Self.Value);

  Self.Value := 2;

  Writeln(‘Value ‘, Value);

  Writeln(‘Self ‘, Self.Value);

end;

Output is

Value 1

Self 0

Value 1

Self 2

 

Janez Atmapuri Makovsek found some #XE6  array optimizations

Janez Atmapuri Makovsek found some #XE6  array optimizations

Inline declared setter and getter functions can yield up to six times the performance on one-dimensional arrays and up to four times the performance on 2D arrays, compared to XE5.

Spotted at the EMBT forums.