Compiler does not check if array property parameters match
Original Reporter info from Mantis: kluug.net @onpok
-
Reporter name: Ondrej Pokorny
Original Reporter info from Mantis: kluug.net @onpok
- Reporter name: Ondrej Pokorny
Description:
When an array property is used in the code, the compiler does not check if the parameters match the property definition. Instead it directly searches an (overloaded) getter/setter function that matches the used parameters.
Both getters and setters are affected.
Steps to reproduce:
type
TObj = class
public
function GetS(Index: Integer): string; overload;
function GetS(Index1, Index2: Integer): Double; overload;
property S[Index: Integer]: string read GetS;
end;
var
o: TObj;
s: string;
d: Double;
begin
o := TObj.Create;
s := o.S[1]; // valid
d := o.S[10, 3]; // !!!
end;
(Full project is attached.)
Mantis conversion info:
- Mantis ID: 28949
- Build: trunk
- Version: 3.1.1
- Monitored by: » @genericptr (Ryan Joseph)