Cause failing assertion for invalid u256 to bool conversion.

This commit is contained in:
chriseth 2020-01-29 18:45:47 +01:00
parent db33ff6408
commit 2bcdb24ebe

View File

@ -266,10 +266,15 @@ EVMDialectTyped::EVMDialectTyped(langutil::EVMVersion _evmVersion, bool _objectA
BuiltinContext&, BuiltinContext&,
std::function<void()> _visitArguments std::function<void()> _visitArguments
) { ) {
// TODO Should a value larger than 1 be invalid? // A value larger than 1 causes an invalid instruction.
_visitArguments(); _visitArguments();
_assembly.appendInstruction(evmasm::Instruction::ISZERO); _assembly.appendConstant(2);
_assembly.appendInstruction(evmasm::Instruction::ISZERO); _assembly.appendInstruction(evmasm::Instruction::DUP2);
_assembly.appendInstruction(evmasm::Instruction::LT);
AbstractAssembly::LabelID inRange = _assembly.newLabelId();
_assembly.appendJumpToIf(inRange);
_assembly.appendInstruction(evmasm::Instruction::INVALID);
_assembly.appendLabel(inRange);
})); }));
m_functions["u256_to_bool"_yulstring].returns = {"bool"_yulstring}; m_functions["u256_to_bool"_yulstring].returns = {"bool"_yulstring};
} }