a unit with an overloaded function that has a generic overload will fail in mode objfpc and works in mode delphi
Original Reporter info from Mantis: Thaddy
-
Reporter name: Thaddy de Koning
Original Reporter info from Mantis: Thaddy
- Reporter name: Thaddy de Koning
Description:
related to 0033829 but the issue is not with RandomFrom at all, so I opened a new issue for clarity.
Given a project that uses a unit with overloaded functions or methods that contains a generic overload, makes the project fail on the used unit in mode objfpc. The same project in mode Delphi works.
Steps to reproduce:
The unit (can also use ObjFpc syntax, does not matter...)
-------------
unit bugme;
{$mode delphi} // mode does not matter!
interface
procedure testme(const a:integer);overload;
procedure testme(const a:cardinal);overload;
procedure testme(const a:double);overload;
procedure testme<T>(const a:T);overload;
implementation
procedure testme(const a:integer);overload;
begin
//
end;
procedure testme(const a:cardinal);overload;
begin
//
end;
procedure testme(const a:double);overload;
begin
//
end;
procedure testme<T>(const a:T);overload;
begin
//
end;
end.
-------------
The program:
program strange;
{$mode objfpc} // change to mode Delphi and it works
uses bugme;
begin
testme(100);
end.
--------------
So
----------
program strange2;
{$mode delphi}
uses bugme;
begin
testme(100);
end.
Additional information:
This bug is likely a regression.
It reproduces on all my platforms.
The compiler output is as follows:
--- mode objfpc -----
fpc -B strange.pas
Free Pascal Compiler version 3.1.1-r39191 [2018/06/07] for arm
Copyright (c) 1993-2018 by Florian Klaempfl and others
Target OS: Linux for ARMHF
Compiling strange.pas
Compiling bugme.pas
strange.pas(5,3) Error: Generics without specialization cannot be used as a type for a variable
strange.pas(7) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/local/bin/ppcarm returned an error exitcode
--------------
-------- mode delphi ----------
fpc -B strange2.pas
Free Pascal Compiler version 3.1.1-r39191 [2018/06/07] for arm
Copyright (c) 1993-2018 by Florian Klaempfl and others
Target OS: Linux for ARMHF
Compiling strange2.pas
Compiling bugme.pas
Linking strange2
34 lines compiled, 0.8 sec
Mantis conversion info:
- Mantis ID: 33839
- OS: all
- OS Build: all
- Build: 39191
- Platform: all
- Version: 3.1.1
- Fixed in version: 3.1.1
- Fixed in revision: 39234 (#c495f10b)