mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Ensure we fail gracefully when user tries to optimize Yul code
This commit is contained in:
parent
0b392fff7e
commit
7751fa740f
@ -6,6 +6,7 @@ Bugfixes:
|
||||
* Type Checker: Dissallow mappings with data locations other than 'storage'
|
||||
* Type Checker: Fix internal error when a struct array index does not fit into a uint256.
|
||||
* Type system: Properly report packed encoded size for arrays and structs (mostly unused until now).
|
||||
* Commandline interface: Allow yul optimizer only for strict assembly.
|
||||
|
||||
|
||||
Language Features:
|
||||
|
@ -84,7 +84,8 @@ bool AssemblyStack::parseAndAnalyze(std::string const& _sourceName, std::string
|
||||
|
||||
void AssemblyStack::optimize()
|
||||
{
|
||||
solAssert(m_language != Language::Assembly, "Optimization requested for loose assembly.");
|
||||
if (m_language != Language::StrictAssembly)
|
||||
solUnimplemented("Optimizer for both loose assembly and Yul is not yet implemented");
|
||||
solAssert(m_analysisSuccessful, "Analysis was not successful.");
|
||||
m_analysisSuccessful = false;
|
||||
optimize(*m_parserResult);
|
||||
|
@ -861,13 +861,11 @@ bool CommandLineInterface::processInput()
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (optimize && inputLanguage == Input::Assembly)
|
||||
if (optimize && inputLanguage != Input::StrictAssembly)
|
||||
{
|
||||
serr() <<
|
||||
"Optimizer cannot be used for loose assembly. Use --" <<
|
||||
"Optimizer can only be used for strict assembly. Use --" <<
|
||||
g_strStrictAssembly <<
|
||||
" or --" <<
|
||||
g_strYul <<
|
||||
"." <<
|
||||
endl;
|
||||
return false;
|
||||
|
@ -332,13 +332,12 @@ printTask "Testing assemble, yul, strict-assembly and optimize..."
|
||||
# Test options above in conjunction with --optimize.
|
||||
# Using both, --assemble and --optimize should fail.
|
||||
! echo '{}' | "$SOLC" - --assemble --optimize &>/dev/null
|
||||
! echo '{}' | "$SOLC" - --yul --optimize &>/dev/null
|
||||
|
||||
# Test yul and strict assembly output
|
||||
# Non-empty code results in non-empty binary representation with optimizations turned off,
|
||||
# while it results in empty binary representation with optimizations turned on.
|
||||
test_solc_assembly_output "{ let x:u256 := 0:u256 }" "{ let x:u256 := 0:u256 }" "--yul"
|
||||
test_solc_assembly_output "{ let x:u256 := 0:u256 }" "{ }" "--yul --optimize"
|
||||
|
||||
test_solc_assembly_output "{ let x := 0 }" "{ let x := 0 }" "--strict-assembly"
|
||||
test_solc_assembly_output "{ let x := 0 }" "{ }" "--strict-assembly --optimize"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user