View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0037895||pas2js||transpiler||public||2020-10-09 07:57||2020-10-09 10:16|
|Reporter||Highball||Assigned To||Mattias Gaertner|
|Status||resolved||Resolution||no change required|
|Summary||0037895: generic method in interface|
|Description||the 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 Reproduce||define an interface with a generic method as such, and try to compile |
IMyTestInterface = interface
|Additional Information||using trunk pas2js pulled 10/8/2020|
|Tags||No tags attached.|
|Fixed in Revision|
Please provide a complete example.
I guess it is a bug in fpc.
This is a bug in FPC.
[dcc32 Error] testgenintf.dpr(13): E2535 Interface methods must not have parameterized methods
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
generic-method-intf.zip (1,562 bytes)
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.
|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: generic-method-intf.zip|
|2020-10-09 10:16||Michael Van Canneyt||Note Added: 0126172|