Compilation failure when a class contains generic for standard type
Original Reporter info from Mantis: ashumkin
-
Reporter name: Alexey Shumkin
Original Reporter info from Mantis: ashumkin
- Reporter name: Alexey Shumkin
Description:
Compilation failure when class is like
TTestGenericEnumerator = class(TInterfacedObject, IEnumerator&LtPos;string>
...
function IEnumerator<string>.GetCurrent = GetCurrentString;
...
with the error
...Fatal: Syntax error, "identifier" expected but "STRING" found
on the line
function IEnumerator<|string>.GetCurrent = GetCurrentString;
(pipe character is the error position)
FPC 3.0.4 compiles this with no errors
Steps to reproduce:
See attached sample program.
It fails to be compiled since r31769 (I've bisected a Git-mirror repository https://github.com/graemeg/freepascal,
commit https://github.com/graemeg/freepascal/commit/e77d57076e96dfcff2af783d5f5f9b37bf56b8f3
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@31769 3ad0048d-3df7-0310-abae-a5850022a9f2
Additional information:
Class like TTestGenericEnumerator = class(TInterfacedObject, IEnumerator&LtPos;Integer>
...
function IEnumerator<Integer>.GetCurrent = GetCurrentString;
...
is compiled with no errors
Also, there is a workaround
TMyString = string;
TTestGenericEnumerator = class(TInterfacedObject, IEnumerator&LtPos;TMyString>
...
function IEnumerator<TMyString>.GetCurrent = GetCurrentString;
...
Mantis conversion info:
- Mantis ID: 35019
- OS: Linux Fedora 25
- Build: 3.1.1
- Platform: Linux x86_64
- Monitored by: » ashumkin (Alexey Shumkin)