pyVHDLModel icon indicating copy to clipboard operation
pyVHDLModel copied to clipboard

Constant in pkg files cause issues in AnalyzeObjects due to _identifiers vs _identifier

Open Tcenova opened this issue 1 year ago • 3 comments

/python3.11/site-packages/pyVHDLModel/init.py", line 705, in _ImportObjects package._namespace._elements[declaredItem._identifier] = declaredItem ^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'Constant' object has no attribute '_identifier'. Did you mean: '_identifiers'?

I assume this may also cause issues with other elements which use _identifiers. I am not sure how to solve this correctly. I have a local workaround to access the zeroth element of _identifiers for now (when declaredItem has the attr _identifiers).

Tcenova avatar Jul 26 '24 19:07 Tcenova

There was once a change in the model, because a constant declaration can have multiple identifiers.

constant a, b : integer := 5;

I thought I found all places referring to _identifier when it was changed to _identifiers. A quick workaround would be defaulting to the first identifier as in many VHDL sources that will be the case.

But at the end the problem needs a solution.

Paebbels avatar Jul 26 '24 21:07 Paebbels

See PR for potential solution. I think it may be the correct route, since it would desirable for a and b to point to the constant type. I used the following as the as the basis for the solution, but generalized it by looking for an attr of the object instead of specific object types. https://github.com/VHDL/pyVHDLModel/blob/8086c3789e069c1d55560094b93c64638633af15/pyVHDLModel/Regions.py#L141-L144
Do you think this is a good solution?

Tcenova avatar Jul 29 '24 13:07 Tcenova

#82 looks good. I proposed a minor change to it.

Paebbels avatar Jul 29 '24 15:07 Paebbels