Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Tcenova opened this issue Jul 26, 2024 · 3 comments · Fixed by #79
Closed
Labels
bug Something isn't working question Further information is requested

Comments

@Tcenova
Copy link
Contributor

Tcenova commented Jul 26, 2024

/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).

@Paebbels
Copy link
Member

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 Paebbels added bug Something isn't working question Further information is requested labels Jul 26, 2024
@Tcenova
Copy link
Contributor Author

Tcenova commented Jul 29, 2024

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.

elif isinstance(item, Constant):
for normalizedIdentifier in item._normalizedIdentifiers:
self._constants[normalizedIdentifier] = item
self._namespace._elements[normalizedIdentifier] = item

Do you think this is a good solution?

@Paebbels
Copy link
Member

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

@Paebbels Paebbels mentioned this issue Jul 29, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants