pyecoregen
pyecoregen copied to clipboard
Wrong code generated for enums
See https://github.com/pyecore/pyecore/issues/126#issuecomment-1255030180
Quoting from there, for enums,
pyecoregen generates the wrong code:
for classif in otherClassifiers: eClassifiers[classif.name] = classif classif.ePackage = eClass for classif in eClassifiers.values(): eClass.eClassifiers.append(classif.eClass)
What happens is that, initially,
eClassifiers
is empty. Then, first, enums are added toeClassifiers
, and then theeClass
of each object ineClassifiers
is added to theEPackage
(that for some reason is calledeClass
). So we have theEEnum
class added to the package we're defining! And, of course, it gets removed from the Ecore package, becauseeClassifiers
is a containment relationship. I don't know the purpose of the secondfor
loop, maybe it was to handle custom metaclasses or stuff like that, but it should filter the classes that it puts intoeClass
, or be removed altogether if it's not necessary.