Object's field can be modified via read-only property on const initialization
Original Reporter info from Mantis: merlin2100
-
Reporter name: Merlin Green
Original Reporter info from Mantis: merlin2100
- Reporter name: Merlin Green
Description:
The code below shows two errors:
- the compiler allow to use read-only property Prop3 on static initialization.
- the compiler actually initializes field Field1.
program BugDemo;
type
MyObjType = object
Field1 : String;
Field2 : String;
Field3 : String;
property Prop3:String read Field3;
end;
var // or const
Obj: MyObjType = (Prop3:'prop3';Field3:'field3'); // actually sets Field1 ?!
begin
writeln(Obj.Field1); // prints 'prop3' ?!
writeln(Obj.Field3); // prints 'field3'
writeln(Obj.Prop3); // prints 'field3'
end.
Mantis conversion info:
- Mantis ID: 16234
- Build: svn r15108
- Version: 2.5.1
- Fixed in version: 2.6.0
- Fixed in revision: 15150 (#72758864)