mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #11003 from ethereum/ir-bug-incorrect-return-variable-count
Fix IR bug on deleting storage variables of function type.
This commit is contained in:
commit
2d48052ae5
@ -3888,11 +3888,13 @@ string YulUtilFunctions::storageSetToZeroFunction(Type const& _type)
|
|||||||
if (_type.isValueType())
|
if (_type.isValueType())
|
||||||
return Whiskers(R"(
|
return Whiskers(R"(
|
||||||
function <functionName>(slot, offset) {
|
function <functionName>(slot, offset) {
|
||||||
<store>(slot, offset, <zeroValue>())
|
let <values> := <zeroValue>()
|
||||||
|
<store>(slot, offset, <values>)
|
||||||
}
|
}
|
||||||
)")
|
)")
|
||||||
("functionName", functionName)
|
("functionName", functionName)
|
||||||
("store", updateStorageValueFunction(_type, _type))
|
("store", updateStorageValueFunction(_type, _type))
|
||||||
|
("values", suffixedVariableNameList("zero_", 0, _type.sizeOnStack()))
|
||||||
("zeroValue", zeroValueFunction(_type))
|
("zeroValue", zeroValueFunction(_type))
|
||||||
.render();
|
.render();
|
||||||
else if (_type.category() == Type::Category::Array)
|
else if (_type.category() == Type::Category::Array)
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
contract C {
|
||||||
|
function() external public x;
|
||||||
|
uint public y = 0;
|
||||||
|
|
||||||
|
function increment() public {
|
||||||
|
++y;
|
||||||
|
}
|
||||||
|
|
||||||
|
function set() external {
|
||||||
|
x = this.increment;
|
||||||
|
}
|
||||||
|
|
||||||
|
function incrementIndirectly() public {
|
||||||
|
x();
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteFunction() public {
|
||||||
|
// used to lead to an ICE during IR
|
||||||
|
delete x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// compileViaYul: also
|
||||||
|
// ----
|
||||||
|
// x() -> 0
|
||||||
|
// y() -> 0
|
||||||
|
// increment() ->
|
||||||
|
// y() -> 1
|
||||||
|
// set() ->
|
||||||
|
// x() -> 0xfdd67305928fcac8d213d1e47bfa6165cd0b87bd09de08a0000000000000000
|
||||||
|
// increment() ->
|
||||||
|
// y() -> 2
|
||||||
|
// incrementIndirectly() ->
|
||||||
|
// y() -> 3
|
||||||
|
// deleteFunction() ->
|
||||||
|
// increment() ->
|
||||||
|
// y() -> 4
|
||||||
|
// incrementIndirectly() -> FAILURE
|
||||||
|
// y() -> 4
|
Loading…
Reference in New Issue
Block a user