Skip to content

Generics with same name as class not always resolved correctly, contrary to Delphi

Summary

Delphi correctly resolves a generic name with the same name as a class name when the class name is being defined.

System Information

  • Operating system: N/A
  • Processor architecture: N/A
  • Compiler version: 3.3.1
  • Device: N/A

Steps to reproduce

Compile below unit tb.

Example Project

Unit ta:

{$IFDEF FPC}
{$mode delphi}
{$ENDIF}
unit ta;

interface

Type
  TObjectList<T> = Class
    aList : array of T;
  end;
  
implementation

end.

Unit tb:

{$IFDEF FPC}
{$mode delphi}
{$ENDIF}
unit tb;

interface

uses ta;

Type
  TObjectList = TObjectList<TObject>;
  
implementation

end.

What is the current bug behavior?

Free Pascal gives an error when compiling tb:

tb.pas(11,17) Error: Illegal expression
tb.pas(11,28) Fatal: Internal error 2019112401

Delphi compiles it.

What is the expected (correct) behavior?

Free Pascal resolves the TObjectList in the type definition to ta.TObjectList

Relevant logs and/or screenshots

Possible fixes

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information