Improve typehash() computation for nested structs

This commit is contained in:
Anton Bukov
2023-07-05 12:34:38 +02:00
parent f9a48b94d4
commit 9b4da6bdea
3 changed files with 37 additions and 12 deletions
@@ -1944,8 +1944,10 @@ void IRGeneratorForStatements::endVisit(MemberAccess const& _memberAccess)
else if (member == "typehash")
{
Type const* arg = dynamic_cast<MagicType const&>(*_memberAccess.expression().annotation().type).typeArgument();
auto const& structType = dynamic_cast<StructType const&>(*arg);
StructDefinition const& struct_ = structType.structDefinition();
solAssert(arg != nullptr);
StructType const* structType = dynamic_cast<StructType const*>(arg);
solAssert(structType != nullptr);
StructDefinition const& struct_ = structType->structDefinition();
define(_memberAccess) << formatNumber(struct_.typehash()) << "\n";
}
else if (member == "min" || member == "max")