[fpc-devel] incompatibility change to default param in trunk?

Martin Frb lazarus at mfriebe.de
Thu Feb 13 02:49:35 CET 2014


PING

On 08/02/2014 19:38, Martin Frb wrote:
> Below works with 2.6.2 but not with trunk
>
> Is that indented?

Surely someone knows, if that is intended?

>
> the wiki says
>>
>>
>>         Default values are now properly typechecked
>>
>>   * *Old behaviour*: The compiler did not detect default values for
>>     parameters of which the type did not in any way correspond to the
>>     parameter type.
>>   * *New behaviour*: The compiler now properly checks whether the
>>     type of the constant matches the parameter's type when parsing
>>     default values.
>>   * *Reason*: Proper type checking is one of the fundamental
>>     properties of the Pascal language; Delphi compatibility.
>>   * *Remedy*: Add a typecast around default values that now result in
>>     compiler errors, or correct the type of such parameters.
>>
>
> "did not in any way correspond to the parameter type"
> it does through the overloaded operator, doesn't it?
>
> Also "add a typecast" (despite that would mean the overloaded operator 
> isn't called),
> the following
>    procedure Test(a:TObject=TObject(1));
> gives
>   project1.lpr(6,36) Error: Illegal expression
> even though 1 can be typecasted into an TObject.
>
>
>
> program project1;
> operator := (a:integer) b: TObject;
> begin
>   b:= TObject.Create;
> end;
> procedure Test(a:TObject=1);
> begin
> end;
> begin
> Test;
> end.
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20140213/cc905000/attachment.html>


More information about the fpc-devel mailing list