Skip to content

Commit 290a6bd

Browse files
committed
eof: Fix errors for instructions deplacated by EOF
1 parent 0370606 commit 290a6bd

File tree

2 files changed

+38
-30
lines changed

2 files changed

+38
-30
lines changed

libyul/AsmAnalysis.cpp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,36 @@ bool AsmAnalyzer::validateInstructions(evmasm::Instruction _instr, SourceLocatio
735735
// The errors below are meant to be issued when processing an undeclared identifier matching a builtin name
736736
// present on the default EVM version but not on the currently selected one,
737737
// since the other `validateInstructions()` overload uses the default EVM version.
738-
if (_instr == evmasm::Instruction::RETURNDATACOPY && !m_evmVersion.supportsReturndata())
738+
if (m_eofVersion.has_value() && (
739+
_instr == evmasm::Instruction::CALL ||
740+
_instr == evmasm::Instruction::CALLCODE ||
741+
_instr == evmasm::Instruction::DELEGATECALL ||
742+
_instr == evmasm::Instruction::STATICCALL ||
743+
_instr == evmasm::Instruction::SELFDESTRUCT ||
744+
_instr == evmasm::Instruction::JUMP ||
745+
_instr == evmasm::Instruction::JUMPI ||
746+
_instr == evmasm::Instruction::PC ||
747+
_instr == evmasm::Instruction::CREATE ||
748+
_instr == evmasm::Instruction::CREATE2 ||
749+
_instr == evmasm::Instruction::CODESIZE ||
750+
_instr == evmasm::Instruction::CODECOPY ||
751+
_instr == evmasm::Instruction::EXTCODESIZE ||
752+
_instr == evmasm::Instruction::EXTCODECOPY ||
753+
_instr == evmasm::Instruction::EXTCODEHASH ||
754+
_instr == evmasm::Instruction::GAS
755+
))
756+
{
757+
m_errorReporter.typeError(
758+
9132_error,
759+
_location,
760+
fmt::format(
761+
"The \"{instruction}\" instruction is {kind} VMs (you are currently compiling to EOF).",
762+
fmt::arg("instruction", boost::to_lower_copy(instructionInfo(_instr, m_evmVersion).name)),
763+
fmt::arg("kind", "only available in legacy bytecode")
764+
)
765+
);
766+
}
767+
else if (_instr == evmasm::Instruction::RETURNDATACOPY && !m_evmVersion.supportsReturndata())
739768
errorForVM(7756_error, "only available for Byzantium-compatible");
740769
else if (_instr == evmasm::Instruction::RETURNDATASIZE && !m_evmVersion.supportsReturndata())
741770
errorForVM(4778_error, "only available for Byzantium-compatible");
@@ -788,35 +817,6 @@ bool AsmAnalyzer::validateInstructions(evmasm::Instruction _instr, SourceLocatio
788817
)
789818
);
790819
}
791-
else if (m_eofVersion.has_value() && (
792-
_instr == evmasm::Instruction::CALL ||
793-
_instr == evmasm::Instruction::CALLCODE ||
794-
_instr == evmasm::Instruction::DELEGATECALL ||
795-
_instr == evmasm::Instruction::STATICCALL ||
796-
_instr == evmasm::Instruction::SELFDESTRUCT ||
797-
_instr == evmasm::Instruction::JUMP ||
798-
_instr == evmasm::Instruction::JUMPI ||
799-
_instr == evmasm::Instruction::PC ||
800-
_instr == evmasm::Instruction::CREATE ||
801-
_instr == evmasm::Instruction::CREATE2 ||
802-
_instr == evmasm::Instruction::CODESIZE ||
803-
_instr == evmasm::Instruction::CODECOPY ||
804-
_instr == evmasm::Instruction::EXTCODESIZE ||
805-
_instr == evmasm::Instruction::EXTCODECOPY ||
806-
_instr == evmasm::Instruction::EXTCODEHASH ||
807-
_instr == evmasm::Instruction::GAS
808-
))
809-
{
810-
m_errorReporter.typeError(
811-
9132_error,
812-
_location,
813-
fmt::format(
814-
"The \"{instruction}\" instruction is {kind} VMs (you are currently compiling to EOF).",
815-
fmt::arg("instruction", boost::to_lower_copy(instructionInfo(_instr, m_evmVersion).name)),
816-
fmt::arg("kind", "only available in legacy bytecode")
817-
)
818-
);
819-
}
820820
else
821821
{
822822
// Sanity check
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
pop(pc())
3+
}
4+
// ====
5+
// bytecodeFormat: >=EOFv1
6+
// ----
7+
// TypeError 9132: (10-12): The "pc" instruction is only available in legacy bytecode VMs (you are currently compiling to EOF).
8+
// TypeError 3950: (10-14): Expected expression to evaluate to one value, but got 0 values instead.

0 commit comments

Comments
 (0)