hexMachina icon indicating copy to clipboard operation
hexMachina copied to clipboard

Detect circular references in DSL and provide a meaningful error message

Open gene-pavlovsky opened this issue 7 years ago • 2 comments

Example code:

snapshotModule = new module.SnapshotModule(snapshotDependencies);
snapshotDependencies = new Array<hex.di.mapping.MappingDefinition>(
	mapping({fromType: "Void->Void", toValue: snapshotController.onSnapshotSaved, withName: "onSnapshotSaved"})
);
snapshotController = new adapter.SnapshotController(snapshotModule.takeSnapshot);

As you can see, there is a circular dependency between snapshotModule and snapshotController, but it might be hard to notice in some cases. Trying to compile the code results in a really long list of errors, none of which are helpful to find the source of the problem.

It would be nice if circular dependencies are detected during building of the dependency graph, and a meaningful error message is produced.

gene-pavlovsky avatar Jun 15 '18 10:06 gene-pavlovsky

This one is tricky (for the edge cases). I will have to think about it in details. Btw, I could develop a 1st iteration for the common ones.

FrancisBourre avatar Jul 31 '18 12:07 FrancisBourre

Yeah I know it's tricky :)

gene-pavlovsky avatar Jul 31 '18 12:07 gene-pavlovsky