[fpc-devel] Local variable names and colision with attributes/properties names
Marcos Douglas
md at delfire.net
Thu Sep 27 15:51:33 CEST 2012
Hi,
What is the advantages to the compiler return the error bellow?
ERROR: unit1.pas(31,3) Error: Duplicate identifier "FooVar"
Why the compiler do not respect the scope, ie, the local variable
should have the preference, I'm not right?
Not? Why I can use a unit name as a property in my class, so? (see
bellow the "StdCtrls" property name).
If I use {mode delphi} I can compile... I know. Why not in {mode objfpc} too?
See an example code:
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
FooVar: string;
StdCtrls: string;
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
procedure TForm1.Button1Click(Sender: TObject);
var
FooVar: string;
begin
FooVar := 'foo';
StdCtrls := 'Is that right?';
end;
end.
Best regards,
Marcos Douglas
More information about the fpc-devel
mailing list