View Issue Details

IDProjectCategoryView StatusLast Update
0037723pas2jstranspilerpublic2020-09-16 23:51
Reporterhenrique Assigned ToMattias Gaertner  
Status assignedResolutionopen 
Summary0037723: Uncaught duplicate type "TEnumerator"
DescriptionWhen I declare two generic lists of different types and use "for X in List do", it gives an error in running JS with the message "Uncaught duplicate type"TEnumerator"".

I've attach a project that generates the error
TagsNo tags attached.
Fixed in Revision
Attached Files



2020-09-08 18:55

reporter (734 bytes)


2020-09-09 22:56

reporter   ~0125453

With several hours of debug, I still haven't been able to figure out where the generic "T" is removed from the GenericTemplateTypes list.

For me this is a critical problem, which is hindering the progress of the development of my system.

If anyone can explain to me where there is this "optimization" that would remove this, it will be of great help.

I've spent several hours here, and I still can't find :'(


2020-09-09 22:59

reporter   ~0125454

Compiling params -MDelphi -JRjs -Jc -vd


2020-09-10 19:32

reporter   ~0125463

I found the problem!

In the unit "Generics.Collections" has the declaration of "TList<T>", in this class has the declaration of "TEnumerator" as an internal type of the class. In the unit "Generics.Collections" has the declaration of "TList<T>", in this class has the declaration of "TEnumerator" as an internal type of the class. When you declare two lists of different types, you generatem two different TEnumerator classes, but in JS generation, it creates both with the same name.

The solution I attach was to concatenate the name of the parent class with the name of the inner class.
Enumerator.patch (809 bytes)   
From a07cb3a49e3dd1ef8d2eab4939356d05de3f4e6f Mon Sep 17 00:00:00 2001
From: Henrique Gottardi Werlang <>
Date: Thu, 10 Sep 2020 14:29:03 -0300
Subject: [PATCH] Ajustado problema enumerador.

 packages/pastojs/src/fppas2js.pp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/packages/pastojs/src/fppas2js.pp b/packages/pastojs/src/fppas2js.pp
index 90926b67f7..b4a0766bf7 100644
--- a/packages/pastojs/src/fppas2js.pp
+++ b/packages/pastojs/src/fppas2js.pp
@@ -6787,6 +6787,8 @@ begin
     if Result<>'' then exit;
+  if (Data is TPas2JSClassScope) and (El.Parent is TPasClassType) then
+    Result:=GetOverloadName(El.Parent)+'$'+Result;
 function TPas2JSResolver.GetBaseDescription(const R: TPasResolverResult;

Enumerator.patch (809 bytes)   

Issue History

Date Modified Username Field Change
2020-09-08 18:55 henrique New Issue
2020-09-08 18:55 henrique File Added:
2020-09-09 22:56 henrique Note Added: 0125453
2020-09-09 22:59 henrique Note Added: 0125454
2020-09-10 19:32 henrique Note Added: 0125463
2020-09-10 19:32 henrique File Added: Enumerator.patch
2020-09-16 23:51 Michael Van Canneyt Assigned To => Mattias Gaertner
2020-09-16 23:51 Michael Van Canneyt Status new => assigned