Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eof: Fix condition when generating custom error for builtins available in EOF but not in legacy #15784

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions libyul/AsmAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,21 +690,22 @@ void AsmAnalyzer::expectValidIdentifier(YulName _identifier, SourceLocation cons
bool AsmAnalyzer::validateInstructions(std::string_view _instructionIdentifier, langutil::SourceLocation const& _location)
{
// NOTE: This function uses the default EVM version instead of the currently selected one.
auto const& defaultEVMDialect = EVMDialect::strictAssemblyForEVM(EVMVersion{}, std::nullopt);
auto const& defaultEVMDialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion{}, std::nullopt);
auto const builtinHandle = defaultEVMDialect.findBuiltin(_instructionIdentifier);
if (builtinHandle && defaultEVMDialect.builtin(*builtinHandle).instruction.has_value())
return validateInstructions(*defaultEVMDialect.builtin(*builtinHandle).instruction, _location);

solAssert(!m_eofVersion.has_value() || (*m_eofVersion == 1 && m_evmVersion == langutil::EVMVersion::prague()));
// TODO: Change `prague()` to `EVMVersion{}` once EOF gets deployed
auto const& eofDialect = EVMDialect::strictAssemblyForEVM(EVMVersion::prague(), 1);
auto const& eofDialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::prague(), 1);
auto const eofBuiltinHandle = eofDialect.findBuiltin(_instructionIdentifier);
if (eofBuiltinHandle)
{
auto const builtin = eofDialect.builtin(*eofBuiltinHandle);
if (builtin.instruction.has_value())
return validateInstructions(*builtin.instruction, _location);
else if (!m_eofVersion.has_value())
// If builtin is available in EOF but not available in legacy (and we build to legacy) generate custom error.
else if (!m_eofVersion.has_value() && !builtinHandle)
{
m_errorReporter.declarationError(
7223_error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// DeclarationError 7223: (6-18): Builtin function "auxdataloadn" is only available in EOF.
// DeclarationError 4619: (26-35): Function "dataloadn" not found.
// DeclarationError 7223: (43-52): Builtin function "eofcreate" is only available in EOF.
// DeclarationError 4619: (77-91): Function "returncontract" not found.
// DeclarationError 7223: (77-91): Builtin function "returncontract" is only available in EOF.
// DeclarationError 4619: (110-115): Function "rjump" not found.
// DeclarationError 4619: (122-128): Function "rjumpi" not found.
// DeclarationError 4619: (135-140): Function "callf" not found.
Expand Down