Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-11

Generic syntax that compiles with FPC 2.4.4 but not with FPC 2.6.0-0.rc1

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Juha Manninen

Regarding this issue:
http://bugs.freepascal.org/bug_view_advanced_page.php?bug_id=20713

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?

Juha

Reply by email

Jonas Maebe
to Juha Manninen: Regarding this issue: http://bugs.freepascal.org/bug_view_advanced_page.php?bug_id=20713…
Juha Manninen wrote 22 lines
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

Reply by email

Juha Manninen
to Jonas Maebe

2011/11/24 Jonas Maebe

Show quoted text 19 lines
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.

Works.
Thanks for the quick answer.

Juha

Reply by email