[fpc-pascal] Generic syntax that compiles with FPC 2.4.4 but not with FPC 2.6.0-0.rc1
Jonas Maebe
jonas.maebe at elis.ugent.be
Wed Nov 23 23:08:06 CET 2011
On 23 Nov 2011, at 23:01, Juha Manninen wrote:
> The following does not compile any more with FPC 2.6.0-0.rc1.
> ---
> generic TGen<_T> = class
> type public
> T_TArray = array of _T;
> var private
> w: T_TArray;
> public
> constructor Create(Value: _T);
> end;
>
> TSpecial = specialize TGen<integer>;
> ---
>
> At line:
> T_TArray = array of _T;
> it says:
> unit1.pas(31,16) Fatal: Syntax error, ":" expected but "=" found
>
> It is either a regression bug in FPC 2.6.0 or a bug in FPC 2.4.4 that got
> fixed.
> Which one is it?
It's related to this: http://wiki.freepascal.org/FPC_New_Features_2.6.0#Better_support_for_Delphi-compatible_classes
The syntax is now:
type
generic TGen<_T> = class
public type
T_TArray = array of _T;
private var
w: T_TArray;
public
constructor Create(Value: _T);
end;
TSpecial = specialize TGen<integer>;
I.e., type, var etc are now inside public/private/protected sections, rather than that you have public/private/protected sections inside type/var blocks (Delphi-compatible and more logical). It should be added to User_Changes_2.6.0 though.
Jonas
More information about the fpc-pascal
mailing list