Codetools have a problem with generics + interface types
Original Reporter info from Mantis: sysrpl
-
Reporter name: Anthony Walter
Original Reporter info from Mantis: sysrpl
- Reporter name: Anthony Walter
Description:
The following wiki link outlines some of the new language features to the FPC bringing in compatibility with Delphi.
http://wiki.freepascal.org/FPC_New_Features_Trunk#Generic_records.2C_arrays_and_procedural_types
Using the new generic language below in Lazarus causes the IDE to generate continual Lazarus parser error messages in the message window. When these errors occur, Lazarus opens and switches to the offending file, highlighting the line such as "function GetEnumerator: IEnumerator&LtPos;T>;". These errors messages and switching to the offending file occur anytime code insight is requested (ctrl+space) or whenever the object inspector row changes on the events tabs. Additionally you cannot add events to components when any unit links to a unit with offending code (example):
{$mode delphi}
type
IEnumerator<T> = interface
function GetCurrent: T;
function MoveNext: Boolean;
property Current: T read GetCurrent;
end;
IEnumerable<T> = interface
function GetEnumerator: IEnumerator<T>; // parser breaks here continually
end;
/path/unitname.pas(75,41) Error: expected end., but T found
The problem is that Lazarus's internal parser does not recognize the < in the line with "function GetEnumerator: IEnumerator&LtPos;T>;" as a valid token, even though the code compiles with FPC 2.7.1 (trunk version) and {$mode delphi} perfectly fine.
Additional information:
Here are the details of my current Lazarus build:
Version: 0.9.31
SVN Revision: 32031
FPC Version: 2.7.1
i386-linux-gtk 2
Mantis conversion info:
- Mantis ID: 20059
- Version: 0.9.31 (SVN)
- Fixed in revision: r32067 (#49baf738)