Bug Report
Problem Description:
The generator uses a Directed Acyclic Graph (DAG) to order definitions in _bundle.py. However, the current implementation only includes edges for inheritance (SuperTypes). It ignores Attribute types, leading to out-of-order definitions. Furthermore, Rosetta allows recursive/circular types (A has B, B has A), which a DAG cannot resolve by design. Inheritance-based cycles are particularly fatal as base classes must be defined before children.
Steps to Reproduce:
- Define two types that refer to each other as attributes.
- Define a child type that inherits from a parent, while the parent refers to the child.
- Import the generated classes.
type CircularA:
b CircularB (1..1)
type CircularB:
a CircularA (1..1)
Test Cases:
type Parent:
child Child (0..1)
type Child extends Parent:
val int (1..1)
Test Cases:
Expected Result:
Definitions should be correctly ordered or forward-referenced using String type hints to allow successful import of the bundle.
Actual Result:
NameError: name '...Parent' is not defined occurs because the generator emitted Child before Parent.
Bug Report
Problem Description:
The generator uses a Directed Acyclic Graph (DAG) to order definitions in
_bundle.py. However, the current implementation only includes edges for inheritance (SuperTypes). It ignores Attribute types, leading to out-of-order definitions. Furthermore, Rosetta allows recursive/circular types (A has B, B has A), which a DAG cannot resolve by design. Inheritance-based cycles are particularly fatal as base classes must be defined before children.Steps to Reproduce:
Test Cases:
JUnit:
PythonCircularDependencyTest.testAttributeCircularDependency([testAttributeCircularDependency](https://github.com/finos/rune-python-generator/blob/main/src/test/java/com/regnosys/rosetta/generator/Python:
test_inheritance_cycle.py.manifest_fail(test_inheritance_cycle)Inheritance Cycle: InheritanceCycle.rosetta
Test Cases:
PythonCircularDependencyTest.testInheritanceCircularDependency(testInheritanceCircularDependency)test_circular_failure.py.manifest_fail(test_circular_failure)Expected Result:
Definitions should be correctly ordered or forward-referenced using String type hints to allow successful import of the bundle.
Actual Result:
NameError: name '...Parent' is not definedoccurs because the generator emittedChildbeforeParent.