Compiler error "duplicate identifier" for parameters of static method of advanced record
Original Reporter info from Mantis: MStoll86
-
Reporter name:
Original Reporter info from Mantis: MStoll86
- Reporter name:
Description:
I work in mode objfpc with the mode switch advancedrecords. When I now create a record like the following,
TMyRecord = record
a : integer;
class function Create(a : integer) : TMyRecord; static;
end;
class function TMyRecord.Create(a : integer) : TMyRecord;
begin
result.a := a;
end;
the compiler says that "a" is a duplicate identifier. I understand this error in cases where the method is NOT a CLASS method, since both the parameter of the method and the field of the class are within the scope of that method
In the class-method-case, however, there should not be an error, since there can not be any confusion about "a". The body of the class method "Create" can not access the field "a" but only the parameter "a" in any case.
I can suppress that behavior by using {$modeswitch duplicatelocals}. As said, however, parameter of class methods and normal fields (i.e. non-static / non-class variables) should not interfere anyway.
Mantis conversion info:
- Mantis ID: 37934
- Version: 3.0.4