concerto icon indicating copy to clipboard operation
concerto copied to clipboard

toAst and fromAst are not identity operation

Open muskanbararia opened this issue 2 years ago • 3 comments

Bug Report 🐛

toAst and fromAst are not identity operation.

Expected Behavior

Ideally, toAst and fromAst should be identity operation.

Current Behavior

They result in a model with contents as undefined

muskanbararia avatar Dec 20 '23 12:12 muskanbararia

The culprit here is that while fromAst populates the manager with model files, it doesn't provide definitions. However getModels relies on definitions being there.

Otherwise fromAst and getAst operations are identity.

ekarademir avatar Dec 20 '23 13:12 ekarademir

I'm not sure this is a bug. In your REPL, the first time you run you are creating an AST from CTO, so the CTO text is also added to the ModelManager. In your second run you just add the AST to the ModelManager and the CTO is not present.

The CTO text is not used by the ModelManager, it is preserved purely for debugging, if added. Hence the definitions is optional in the ModelFile constructor.

@mttrbrts perhaps we should drop support for addModel / addCTOModel take a CTO string in ModelManager for v4? This would make concerto-core independent of CTO parser (saving memory and module size).

dselman avatar Dec 20 '23 16:12 dselman

@mttrbrts perhaps we should drop support for addModel / addCTOModel take a CTO string in ModelManager for v4? This would make concerto-core independent of CTO parser (saving memory and module size).

I agree with that.

Perhaps the confusion stems from getModels returning the CML content? What should the behaviour be if a ModelManager doesn't know about the CML? To only list the namespaces, perhaps?

mttrbrts avatar Dec 20 '23 16:12 mttrbrts