NIL is not implicitly typecast to TObject descendant
Original Reporter info from Mantis: Penilopa P
-
Reporter name: Anton
Original Reporter info from Mantis: Penilopa P
- Reporter name: Anton
Description:
Here is the program p.pp:
{$mode objfpc}
type
TMyObject = class
public
constructor Create(ar: array of TMyObject);
end;
constructor TMyObject.Create(ar: array of TMyObject);
begin
end;
begin
TMyObject.Create([nil]);
end.
It cannot be compiled:
p.pp(13,25) Error: Incompatible type for arg no. 1: Got "Array Of Const/Constant Open Array of Pointer", expected "Open Array Of TMyObject"
But if the 13-th line is changed to
TMyObject.Create([TMyObject(nil)]);
the error will disappear.
D7 compiles it without any errors.
Mantis conversion info:
- Mantis ID: 19452
- Version: 2.5.1
- Fixed in version: 3.0.0
- Fixed in revision: 28862 (#f1c45eea)