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

Martin Frb lazarus at mfriebe.de
Sat Feb 8 20:38:46 CET 2014

Below works with 2.6.2 but not with trunk

Is that indented?

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));
   project1.lpr(6,36) Error: Illegal expression
even though 1 can be typecasted into an TObject.

program project1;
operator := (a:integer) b: TObject;
   b:= TObject.Create;
procedure Test(a:TObject=1);

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

More information about the fpc-devel mailing list