Procedure with default parameters cannot be assigned to properties
Original Reporter info from Mantis: smcilwain
-
Reporter name: Sean J McIlwain
Original Reporter info from Mantis: smcilwain
- Reporter name: Sean J McIlwain
Description:
The following code does not compile with two errors.
Assigning a procedure with default parameter to a property
(33,7) Error: Incompatible types: got "untyped" expected "&LtPos;procedure variable type of procedure(TObject) of object;Register>"
Passing a procedure into a method.
(35,9) Error: Incompatible types: got "untyped" expected "&LtPos;procedure variable type of procedure(TObject) of object;Register>"
Assigning a procedure directly to a field does work and this code compiles under delphi.
Additional information:
{$MODE DELPHI}
unit bug1;
interface
type
TEvent = procedure(A : TObject) of object;
TTest = class
private
FProc: TEvent;
procedure Proc1(A : TObject);
procedure Proc2(A : TObject = nil);
public
constructor Create;
procedure B(A : TEvent);
property A : TEvent read FProc write FProc;
end;
implementation
constructor TTest.Create;
begin
FProc := Proc1;
FProc := Proc2;
A := Proc1;
A := Proc2;
B(Proc1);
B(Proc2);
end;
Mantis conversion info:
- Mantis ID: 11771
- Version: 2.3.1
- Fixed in version: 2.4.0
- Fixed in revision: 13400 (#754696d1)
- Monitored by: » MSpider (Kirill Boyarkin), » smcilwain (Sean J McIlwain)