diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 5d52feefa860..7d1155ec2084 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1692,7 +1692,6 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) } case FunctionType::Kind::WithdrawReward: { - _functionCall.expression().accept(*this); m_context << Instruction::NATIVEWITHDRAWREWARD; break; } @@ -1720,13 +1719,11 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) } case FunctionType::Kind::CancelAllUnfreezeV2: { - _functionCall.expression().accept(*this); m_context << Instruction::NATIVECANCELALLUNFREEZEV2; break; } case FunctionType::Kind::WithdrawExpireUnfreeze: { - _functionCall.expression().accept(*this); m_context << Instruction::NATIVEWITHDRAWEXPIREUNFREEZE; break; } @@ -2180,7 +2177,7 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) ); } else if ((std::set{"tokenBalance", "call", "callcode", "delegatecall", "staticcall", - "freezeExpireTime", "totalFrozenBalance", "frozenBalance", "frozenBalanceUsage"}).count(member)) + "freezeExpireTime"}).count(member)) utils().convertType( *_memberAccess.expression().annotation().type, *TypeProvider::address(), diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index 44c85b7d5d6d..887df6ab34a3 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -1904,7 +1904,22 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) solAssert(!_functionCall.annotation().tryCall); solAssert(!functionType->valueSet()); solAssert(!functionType->gasSet()); - if (functionType->kind() < FunctionType::Kind::AvailableUnfreezeV2Size) + // Only the address-member reads in this block carry a bound first argument (the address). + // Match them by kind rather than by enum ordering so that reordering FunctionType::Kind + // in Types.h cannot silently invalidate this consistency check. + static std::set const boundFirstArgumentKinds = { + FunctionType::Kind::AvailableUnfreezeV2Size, + FunctionType::Kind::UnfreezableBalanceV2, + FunctionType::Kind::ExpireUnfreezeBalanceV2, + FunctionType::Kind::DelegatableResource, + FunctionType::Kind::ResourceV2, + FunctionType::Kind::CheckUnDelegateResource, + FunctionType::Kind::ResourceUsage, + FunctionType::Kind::TotalResource, + FunctionType::Kind::TotalDelegatedResource, + FunctionType::Kind::TotalAcquiredResource, + }; + if (!boundFirstArgumentKinds.count(functionType->kind())) solAssert(!functionType->hasBoundFirstArgument()); static std::map precompiles = {