View Issue Details

IDProjectCategoryView StatusLast Update
0025927LazarusIDEpublic2020-07-31 10:04
ReporterFelipe Monteiro de Carvalho Assigned ToMattias Gaertner  
PrioritynormalSeverityminorReproducibilityalways
Status feedbackResolutionopen 
Platformx86 intelOSMandrake Linux and Windows XP 
Product Version1.2.1 (SVN) 
Summary0025927: Generic Type declared inside class after methods stops find declaration
DescriptionSteps to reproduce:

1> In the example program bellow, right click in TManagedVector from the line "local: TManagedVector;" and select "Find declaration"

Result:

project1.lpr(17,22) Error: : expected, but = found

The program compiles fine.

Example program:


program Project1;

{$mode objfpc}{$H+}

uses
  Classes
  { you can add units after this };

type
  generic TManagedVector<_TYPE> = class(TObject)
  public type
       // Standard constructor, reserves InitialCapacity slots for the array.
       // The vector capacity is doubled each time it runs out of space. Initial
       // size is 0, use Resize or Push to increase size.
       constructor Create( InitialCapacity : DWord = 16);

       TSortFunction = function( const a : _TYPE; const b : _TYPE ) : Boolean of object;
    var public

constructor TManagedVector.Create( InitialCapacity : DWord = 16);
begin
end;

var
  local: TManagedVector;
begin
end.
TagsNo tags attached.
Fixed in Revision
LazTarget-
Widgetset
Attached Files

Relationships

related to 0023903 closedMattias Gaertner Complete code error 

Activities

Mattias Gaertner

2017-11-28 16:07

manager   ~0104332

The example does not compile here.
It looks as if some lines are shuffled in the example.

Please provide an example that compiles.

delfion

2020-05-14 16:48

reporter   ~0122794

Compilable example

program Project1;

{$mode objfpc}{$H+}

uses
  Classes
  { you can add units after this };

type
  generic TManagedVector<_TYPE> = class(TObject)
  public type
       // Standard constructor, reserves InitialCapacity slots for the array.
       // The vector capacity is doubled each time it runs out of space. Initial
       // size is 0, use Resize or Push to increase size.

       constructor Create( InitialCapacity : DWord = 16);
       TSortFunction = function( const a : _TYPE; const b : _TYPE ) : Boolean of object;

  end;

constructor TManagedVector.Create( InitialCapacity : DWord = 16);
begin
end;

var
  local: specialize TManagedVector<byte>;
begin
end.

Pascal Riekenberg

2020-05-14 21:31

developer   ~0122805

Strange that this is compileable.
The constructor should implicitly end the type section but there is no error when defining the type after the constructor.
Codetools work when:
a) you put "public type" ahead of "TSortFunction = ..."
or b) you put "TSortFunction = ..." ahead of the constructor

Sven Barth

2020-05-15 13:23

manager   ~0122817

I'll need to recheck, but it can indeed be that this shouldn't be able to compile.

Sven Barth

2020-05-17 15:49

manager   ~0122879

Last edited: 2020-05-17 15:49

View 2 revisions

Okay, Delphi already complains about the "constructor" keyword, so this is definitely a bug in FPC, one that will be fixed.

Pascal Riekenberg

2020-07-30 09:21

developer   ~0124409

>so this is definitely a bug in FPC, one that will be fixed.

@Sven: Is this bug added to fpc already?

Issue History

Date Modified Username Field Change
2014-03-27 13:59 Felipe Monteiro de Carvalho New Issue
2014-03-27 13:59 Felipe Monteiro de Carvalho Status new => assigned
2014-03-27 13:59 Felipe Monteiro de Carvalho Assigned To => Mattias Gaertner
2015-12-10 15:12 Mattias Gaertner Relationship added related to 0023903
2017-11-28 16:07 Mattias Gaertner Note Added: 0104332
2017-11-28 16:07 Mattias Gaertner Status assigned => feedback
2020-05-14 16:48 delfion Note Added: 0122794
2020-05-14 21:31 Pascal Riekenberg Note Added: 0122805
2020-05-15 13:23 Sven Barth Note Added: 0122817
2020-05-17 15:49 Sven Barth Note Added: 0122879
2020-05-17 15:49 Sven Barth Note Edited: 0122879 View Revisions
2020-07-30 09:21 Pascal Riekenberg Note Added: 0124409