On 7/30/25 13:01, Martin Frb via fpc-devel wrote:
On 30/07/2025 12:23, Mattias Gaertner via fpc-devel wrote:
[...]
pas2js compiles it.
OTOH pas2js currently creates 3 internal specializations for each TFoo and TBar.

There should only be

TFoo<Byte, Boolean>
TFoo<Boolean, Byte>

Yes.
Well, actually, in your example you don't use them, so pas2js omits a lot.

But internally while resolving the code it already creates a specialization for F

  generic TFoo<A, B> = class
    F:specialize TBar<A,B>;

with the generic template parameter A and B, so it can resolve and check the generic code. This specialization is never transpiled to code. It merely exists for type checking. It's a todo to create less of these internal specializations.


If you got 3 then you got one of them twice. And if they are different types, then at some point you get issues with assigning them to the fields?

Each generic type in pas2js has a list of specializations with each combination of parameters unique. This is enough for simple programs, but for packages Delphi supports duplicate specializations.


Mattias

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to