mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Legacy codegeneration for immutable state variables.
This commit is contained in:
committed by
chriseth
parent
83cbfbb7bf
commit
04d8ad2ae1
@@ -0,0 +1,20 @@
|
||||
contract D {
|
||||
function f() external view returns (uint256) {
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
contract C {
|
||||
D d;
|
||||
function() external view returns(uint256) immutable z;
|
||||
constructor() public {
|
||||
d = new D();
|
||||
z = d.f;
|
||||
}
|
||||
function f() public view returns (uint256) {
|
||||
assert(z.address == address(d));
|
||||
assert(z.selector == D.f.selector);
|
||||
return z();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// f() -> 42
|
||||
@@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
uint256 immutable x;
|
||||
uint256 immutable y;
|
||||
constructor() public {
|
||||
x = 42;
|
||||
y = x;
|
||||
}
|
||||
function f() public view returns (uint256, uint256) {
|
||||
return (x+x,y);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// f() -> 84, 42
|
||||
@@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
uint256 immutable x;
|
||||
uint256 immutable y;
|
||||
constructor() public {
|
||||
x = 42;
|
||||
y = 23;
|
||||
}
|
||||
function f() public view returns (uint256, uint256) {
|
||||
return (x+x,y);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// f() -> 84, 23
|
||||
Reference in New Issue
Block a user