Skip to content

Commit 4436907

Browse files
committed
eof: Add better message when EOF builtin used in legcy
1 parent b202600 commit 4436907

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

libyul/AsmAnalysis.cpp

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,11 +695,28 @@ bool AsmAnalyzer::validateInstructions(std::string_view _instructionIdentifier,
695695
if (builtinHandle && defaultEVMDialect.builtin(*builtinHandle).instruction.has_value())
696696
return validateInstructions(*defaultEVMDialect.builtin(*builtinHandle).instruction, _location);
697697

698+
solAssert(!m_eofVersion.has_value() || (*m_eofVersion == 1 && m_evmVersion == langutil::EVMVersion::prague()));
698699
// TODO: Change `prague()` to `EVMVersion{}` once EOF gets deployed
699700
auto const& eofDialect = EVMDialect::strictAssemblyForEVM(EVMVersion::prague(), 1);
700701
auto const eofBuiltinHandle = eofDialect.findBuiltin(_instructionIdentifier);
701-
if (eofBuiltinHandle && eofDialect.builtin(*eofBuiltinHandle).instruction.has_value())
702-
return validateInstructions(*eofDialect.builtin(*eofBuiltinHandle).instruction, _location);
702+
if (eofBuiltinHandle)
703+
{
704+
auto const builtin = eofDialect.builtin(*eofBuiltinHandle);
705+
if (builtin.instruction.has_value())
706+
return validateInstructions(*builtin.instruction, _location);
707+
else if (!m_eofVersion.has_value())
708+
{
709+
m_errorReporter.declarationError(
710+
7223_error,
711+
_location,
712+
fmt::format(
713+
"Builtin function \"{}\" is only available in EOF.",
714+
fmt::arg("function", _instructionIdentifier)
715+
)
716+
);
717+
return true;
718+
}
719+
}
703720

704721
return false;
705722
}
@@ -716,8 +733,16 @@ bool AsmAnalyzer::validateInstructions(evmasm::Instruction _instr, SourceLocatio
716733
yulAssert(
717734
_instr != evmasm::Instruction::JUMP &&
718735
_instr != evmasm::Instruction::JUMPI &&
719-
_instr != evmasm::Instruction::JUMPDEST,
720-
"");
736+
_instr != evmasm::Instruction::JUMPDEST &&
737+
_instr != evmasm::Instruction::DATALOADN &&
738+
_instr != evmasm::Instruction::EOFCREATE &&
739+
_instr != evmasm::Instruction::RETURNCONTRACT &&
740+
_instr != evmasm::Instruction::RJUMP &&
741+
_instr != evmasm::Instruction::RJUMPI &&
742+
_instr != evmasm::Instruction::CALLF &&
743+
_instr != evmasm::Instruction::JUMPF &&
744+
_instr != evmasm::Instruction::RETF
745+
);
721746

722747
auto errorForVM = [&](ErrorId _errorId, std::string const& vmKindMessage) {
723748
m_errorReporter.typeError(

0 commit comments

Comments
 (0)