Use same register for variables with the same id #1363
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello
This fixes a problem I found recently when using multiple modules and no instances. Currently, our registers (which store values for state variables) are indexed by both the variable name and variable id. We already had some code ensuring that, if two variables have the same name (but a different id), they'd have the same register - this is important for instances, and flattening ensures that no two different state variables can have the same name.
Now, I'm adding a very similar piece of code to ensure variables with the same id get the same register, even if they have different names. This part is important for imports, since qualified imports can make it so the same variable is referred by different names.
I'm not confident this will work for all combinations of imports and instances, but it definitely covers more ground than what we currently have.
For testing, I just updated the existing
imports.qnt
example to have the complexity needed to hit the problem (fixed by this).CHANGELOG.md
for any new functionalityREADME.md
updated for any listed functionality