View Issue Details

IDProjectCategoryView StatusLast Update
0037895pas2jstranspilerpublic2020-10-09 10:16
ReporterHighball Assigned ToMattias Gaertner  
Status resolvedResolutionno change required 
Summary0037895: generic method in interface
Descriptionthe same code compiles in mode delphi using fpc compiler, but when compiling using pas2js I get the following error:
Project1.pas(12,19) Error: interface methods cannot have type parameters

just wondering if this is something "can" be addressed or if there is a limitation for browser?
Steps To Reproducedefine an interface with a generic method as such, and try to compile

IMyTestInterface = interface
    procedure Test<T>;
Additional Informationusing trunk pas2js pulled 10/8/2020
TagsNo tags attached.
Fixed in Revision
Attached Files


Mattias Gaertner

2020-10-09 09:09

manager   ~0126168

Please provide a complete example.
I guess it is a bug in fpc.

Michael Van Canneyt

2020-10-09 09:16

administrator   ~0126169

This is a bug in FPC.

Delphi reports:
[dcc32 Error] testgenintf.dpr(13): E2535 Interface methods must not have parameterized methods


2020-10-09 09:34

reporter   ~0126170

So after reading @Mattias' comment first I could've sworn I've made generic methods in interfaces before.. but I guess I worked around the limitation by making global generic methods, then seeing @Michael, I verified that fpc does indeed report an error when trying to implement the interface (not on defining it, that works fine). I've attached my sample with two compilation targets (browser / windows) and pas2js correctly reports the error but fpc does not (although... it would be very nice to have generic methods in interfaces.. but I don't have the backstory as to why this is prevented).

If this needs to be changed to fpc, I'm not sure I have permissions to do so

Michael Van Canneyt

2020-10-09 10:16

administrator   ~0126172

Interfaces cannot have generic methods, since they are by definition tables of known methods.
With a generic method you simply don't know the method and cannot construct the table.

It's better to create a new bugreport in FPC, with the correct bug: namely, parsing such interface should not be allowed.

Issue History

Date Modified Username Field Change
2020-10-09 07:57 Highball New Issue
2020-10-09 09:09 Mattias Gaertner Assigned To => Mattias Gaertner
2020-10-09 09:09 Mattias Gaertner Status new => feedback
2020-10-09 09:09 Mattias Gaertner Note Added: 0126168
2020-10-09 09:16 Michael Van Canneyt Status feedback => resolved
2020-10-09 09:16 Michael Van Canneyt Resolution open => no change required
2020-10-09 09:16 Michael Van Canneyt Note Added: 0126169
2020-10-09 09:34 Highball Note Added: 0126170
2020-10-09 09:34 Highball File Added:
2020-10-09 10:16 Michael Van Canneyt Note Added: 0126172