I face some common IDE bugs in Delphi XE2 (RAD Studio) but the problems themselves aren't my concern. It's the result of one of these bugs which made me stumble on something else.
Somehow, auto-completion decided to destroy a few methods of a form, so what used to be...
procedure TForm1.Button1Click(Sender: TObject);
in the implementation became something like...
procedure TForm1.Buproced(Sendure :);
(Not exact, but to some extent like that)
So, I had to manually fix these methods. However, I accidentally fixed one of them to...
procedure TForm1.Button1Click;
although it was supposed to have been...
procedure TForm1.Button1Click(Sender: TObject);
yet it still compiled and ran fine.
To test, start a new VCL Forms Application and drop just one TButton
control, make an event handler for OnClick
, and change its procedure to...
procedure TForm1.Button1Click;
var
B: TButton;
begin
B:= TButton(Sender);
B.Caption:= 'Something';
end;
Is this supposed to be possible? Or is it perhaps an IDE and/or compiler bug?
In Delphi, you can omit the parameters in the implementation. It's not a bug, it's a feature.
The proper method signature is evaluated by the declaration in interface section.
This is an intentional and documented feature of the language. This is the part of the documentation that describes this feature, with my added emphasis:
While a class can be declared in either the interface or the implementation section of a unit, defining declarations for a class methods must be in the implementation section.
In the heading of a defining declaration, the method name is always qualified with the name of the class to which it belongs. The heading can repeat the parameter list from the class declaration; if it does, the order, type, and names of the parameters must match exactly, and if the method is a function, the return value must match as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With