mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6207 from ethereum/fixStructuralVisitationOrder
Fix visitation order bug for structural simplifier.
This commit is contained in:
commit
0f336f30ca
@ -13,6 +13,7 @@ Compiler Features:
|
|||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
* Type system: Detect if a contract's base uses types that require the experimental abi encoder while the contract still uses the old encoder
|
* Type system: Detect if a contract's base uses types that require the experimental abi encoder while the contract still uses the old encoder
|
||||||
|
* Yul Optimizer: Fix visitation order bug for the structural simplifier.
|
||||||
|
|
||||||
|
|
||||||
Build System:
|
Build System:
|
||||||
|
@ -104,10 +104,12 @@ OptionalStatements reduceSingleCaseSwitch(Switch& _switchStmt)
|
|||||||
s->emplace_back(If{
|
s->emplace_back(If{
|
||||||
std::move(_switchStmt.location),
|
std::move(_switchStmt.location),
|
||||||
make_unique<Expression>(FunctionalInstruction{
|
make_unique<Expression>(FunctionalInstruction{
|
||||||
std::move(loc),
|
std::move(loc),
|
||||||
solidity::Instruction::EQ,
|
solidity::Instruction::EQ,
|
||||||
{std::move(*switchCase.value), std::move(*_switchStmt.expression)}
|
{std::move(*switchCase.value), std::move(*_switchStmt.expression)}
|
||||||
}), std::move(switchCase.body)});
|
}),
|
||||||
|
std::move(switchCase.body)
|
||||||
|
});
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -202,10 +204,11 @@ void StructuralSimplifier::simplify(std::vector<yul::Statement>& _statements)
|
|||||||
_statements,
|
_statements,
|
||||||
[&](Statement& _stmt) -> OptionalStatements
|
[&](Statement& _stmt) -> OptionalStatements
|
||||||
{
|
{
|
||||||
visit(_stmt);
|
|
||||||
OptionalStatements result = boost::apply_visitor(visitor, _stmt);
|
OptionalStatements result = boost::apply_visitor(visitor, _stmt);
|
||||||
if (result)
|
if (result)
|
||||||
simplify(*result);
|
simplify(*result);
|
||||||
|
else
|
||||||
|
visit(_stmt);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
// This tests that a bug is fixed where x := 1 was wrongfully
|
||||||
|
// taken into account before actually visiting the if statement.
|
||||||
|
let x := 0
|
||||||
|
if x {
|
||||||
|
x := 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// structuralSimplifier
|
||||||
|
// {
|
||||||
|
// let x := 0
|
||||||
|
// }
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
let y := 200
|
let y := 200
|
||||||
switch y
|
switch calldataload(0)
|
||||||
case 0 { }
|
case 0 { }
|
||||||
case 1 { y := 9 }
|
case 1 { y := 9 }
|
||||||
default { y := 100 }
|
default { y := 100 }
|
||||||
@ -9,7 +9,7 @@
|
|||||||
// structuralSimplifier
|
// structuralSimplifier
|
||||||
// {
|
// {
|
||||||
// let y := 200
|
// let y := 200
|
||||||
// switch y
|
// switch calldataload(0)
|
||||||
// case 0 {
|
// case 0 {
|
||||||
// }
|
// }
|
||||||
// case 1 {
|
// case 1 {
|
||||||
|
Loading…
Reference in New Issue
Block a user