@@ -1552,10 +1552,13 @@ void CompilerUtils::storeStringData(bytesConstRef _data)
15521552unsigned CompilerUtils::loadFromMemoryHelper (Type const & _type, bool _fromCalldata, bool _padToWords)
15531553{
15541554 solAssert (_type.isValueType (), " " );
1555+ Type const * type = &_type;
1556+ if (auto const * userDefined = dynamic_cast <UserDefinedValueType const *>(type))
1557+ type = &userDefined->underlyingType ();
15551558
1556- unsigned numBytes = _type. calldataEncodedSize (_padToWords);
1559+ unsigned numBytes = type-> calldataEncodedSize (_padToWords);
15571560 bool isExternalFunctionType = false ;
1558- if (auto const * funType = dynamic_cast <FunctionType const *>(&_type ))
1561+ if (auto const * funType = dynamic_cast <FunctionType const *>(type ))
15591562 if (funType->kind () == FunctionType::Kind::External)
15601563 isExternalFunctionType = true ;
15611564 if (numBytes == 0 )
@@ -1570,21 +1573,20 @@ unsigned CompilerUtils::loadFromMemoryHelper(Type const& _type, bool _fromCallda
15701573 splitExternalFunctionType (true );
15711574 else if (numBytes != 32 )
15721575 {
1573- bool leftAligned = _type.category () == Type::Category::FixedBytes;
15741576 // add leading or trailing zeros by dividing/multiplying depending on alignment
15751577 unsigned shiftFactor = (32 - numBytes) * 8 ;
15761578 rightShiftNumberOnStack (shiftFactor);
1577- if (leftAligned)
1579+ if (type-> leftAligned () )
15781580 {
15791581 leftShiftNumberOnStack (shiftFactor);
15801582 cleanupNeeded = false ;
15811583 }
1582- else if (IntegerType const * intType = dynamic_cast <IntegerType const *>(&_type ))
1584+ else if (IntegerType const * intType = dynamic_cast <IntegerType const *>(type ))
15831585 if (!intType->isSigned ())
15841586 cleanupNeeded = false ;
15851587 }
15861588 if (_fromCalldata)
1587- convertType (_type, _type , cleanupNeeded, false , true );
1589+ convertType (_type, *type , cleanupNeeded, false , true );
15881590
15891591 return numBytes;
15901592}
@@ -1639,12 +1641,10 @@ unsigned CompilerUtils::prepareMemoryStore(Type const& _type, bool _padToWords,
16391641 " Memory store of more than 32 bytes requested (Type: " + _type.toString (true ) + " )."
16401642 );
16411643
1642- bool leftAligned = _type.category () == Type::Category::FixedBytes;
1643-
16441644 if (_cleanup)
16451645 convertType (_type, _type, true );
16461646
1647- if (numBytes != 32 && !leftAligned && !_padToWords)
1647+ if (numBytes != 32 && !_type. leftAligned () && !_padToWords)
16481648 // shift the value accordingly before storing
16491649 leftShiftNumberOnStack ((32 - numBytes) * 8 );
16501650
0 commit comments