Primož Gabrijelčič 223 Posted July 8, 2019 Hi all, Somehow I think that the following code should compile, but it does not. It looks like the compiler uses the wrong `TCallback` definition when resolving the property. Am I correct or did I miss something and I'm just stupid? program Project184; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; type TCallback = reference to procedure (value: int64); TRunner = class public type TCallback = reference to procedure; strict private FOnCallback: TCallback; public procedure Run; property OnCallback: TCallback read FOnCallback write FOnCallback; end; procedure TRunner.Run; begin OnCallback(); // <-- E2035 Not enough actual parameters end; begin end. Delphi 10.3.1, in case this is a regression bug. Share this post Link to post
PeterBelow 238 Posted July 8, 2019 Well, TRunner.TCallback is closer in scope, so I would expect the compiler to use it instead of the global TCallback, so that does look like a bug. Should be easy enough to work around, though, just specify TRunner.TCallback as type for the property and its field. Of course it's a bit problematic to have this kind of nameing conflict in the first place, not (only) for the compiler but also for a programmer trying to make sense of the code 😉. Delphi 10.3 Version 26.0.33219.4899 still shows this behaviour, by the way. 1 Share this post Link to post
Primož Gabrijelčič 223 Posted July 8, 2019 Indeed, a workaround is not a problem. The bug in itself is, though 😞 Share this post Link to post
Primož Gabrijelčič 223 Posted July 9, 2019 Reported, please vote: https://quality.embarcadero.com/browse/RSP-24827 Share this post Link to post