mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9184 from ethereum/fixUsingForStorage
Fix using for with explicit reference types.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
struct Struct { uint x; }
|
||||
|
||||
library L {
|
||||
function f(Struct storage _x) internal view returns (uint256) {
|
||||
return _x.x;
|
||||
}
|
||||
}
|
||||
|
||||
contract C {
|
||||
using L for Struct;
|
||||
|
||||
Struct s;
|
||||
|
||||
function h(Struct storage _s) internal view returns (uint) {
|
||||
// _s is pointer
|
||||
return _s.f();
|
||||
}
|
||||
function g() public returns (uint, uint) {
|
||||
s.x = 7;
|
||||
// s is reference
|
||||
return (s.f(), h(s));
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// g() -> 7, 7
|
||||
Reference in New Issue
Block a user