diff options
-rw-r--r-- | libsolidity/codegen/CompilerUtils.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index 5e045996..ad155b13 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -661,7 +661,8 @@ void CompilerUtils::convertType(Type const& _typeOnStack, Type const& _targetTyp if (targetTypeCategory == Type::Category::Enum) { EnumType const& enumType = dynamic_cast<decltype(enumType)>(_targetType); - m_context << u256(enumType.numberOfMembers()) << Instruction::DUP2 << Instruction::LT << Instruction::ISZERO; + solAssert(enumType.numberOfMembers() > 0, "empty enum should have caused a parser error."); + m_context << u256(enumType.numberOfMembers() - 1) << Instruction::DUP2 << Instruction::GT; m_context.appendConditionalJumpTo(m_context.errorTag()); } } |