essential-contributions / pint

Pint, the constraint-based programming language for declarative blockchains
Apache License 2.0
17 stars 3 forks source link

Nested aliases aren't lowered correctly. #782

Closed otrho closed 2 months ago

otrho commented 3 months ago

This doesn't seem to have lowered the inner alias. This should happen in transform::lower_aliases() in lower.rs.

When glancing at the code in there I see it has a recursive inner function for finding alias types and replacing them with the aliased type, but it doesn't go further when the replace type is also an alias.

So here it's replacing MyNestMap with (MyInt => int) but it doesn't bother continuing to replace MyInt with int. I have a feeling this is a problem in general, not just this PR. As in an alias of an alias probably won't be lowered properly for var or state types either.

The solution I think is to iterate until there are no changes/replacements made, in the same fashion as other transformation passes, since the replacing type could itself be quite complex and have many nested type aliases.

_Originally posted by @otrho in https://github.com/essential-contributions/pint/pull/780#discussion_r1683661569_