[Lazarus] How well should Lazarus check method parameters?
Mark Morgan Lloyd
markMLl.lazarus at telemetry.co.uk
Thu Feb 23 10:39:57 CET 2012
Mattias Gaertner wrote:
> On Thu, 23 Feb 2012 07:07:47 +0000
> Mark Morgan Lloyd <markMLl.lazarus at telemetry.co.uk> wrote:
>
>> Mattias Gaertner wrote:
>>> On Wed, 22 Feb 2012 20:55:01 +0000
>>> Mark Morgan Lloyd <markMLl.lazarus at telemetry.co.uk> wrote:
>>>
>>>> I've just spotted this in my code:
>>>>
>>>> procedure FormCloseQuery(Sender: TObject; CanClose: boolean);
>>>> ..
>>>> procedure TListForm.FormCloseQuery(Sender: TObject; CanClose: Boolean);
>>>>
>>>> Those were inserted by some old version of the IDE, presumably the
>>>> current version inserts the missing var.
>>> I don't remember such a bug, but I'm not sure. Maybe it was there for a
>>> very short time and you were just unlucky.
>> Only thing there is that I roughed that program out a long time before I
>> was getting Lazarus from svn, so it might in fact be in one or more
>> releases. Appears to be OK at 0.9.24.1, so it's fairly unlikely that
>> anybody's still using an affected copy.
>>
>>>> Shouldn't either the IDE or the runtimes pick up this error?
>>> It's valid code. What do you expect?
>> I'd expect the trunk IDE or runtimes to realise that the second
>> parameter isn't compatible with the current definitions.
>
> Ah, now I see what you mean:
>
> TCloseQueryEvent = procedure(Sender : TObject; var CanClose : boolean) of object;
>
> And you have
>
> procedure TListForm.FormCloseQuery(Sender: TObject; CanClose: Boolean);
>
> Yes, the IDE adds the var when the event is created. I don't know when
> this was implemented - a long time ago.
I suspect this code was originally roughed out in the middle of '06, I
can see comments in there from August of that year.
> There is currently no tool to fix the signatures.
> The LFM / TReader does not check either.
>
> You can create feature requests if you like.
I'll double-check the situation later with trunk and a trivial example
and will file a report to get it into the record.
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
More information about the Lazarus
mailing list