Accessors for immutable variables.

This commit is contained in:
chriseth
2020-04-02 19:09:54 +02:00
parent bdcfd71f34
commit d7a39c86ce
5 changed files with 49 additions and 7 deletions
@@ -0,0 +1,12 @@
contract C {
function() external returns (uint, uint) immutable public x = this.f;
function f() external pure returns (uint, uint) {
return (1, 2);
}
function test() external returns (uint, uint) {
return this.x()();
}
}
// ----
// test() -> 1, 2
@@ -0,0 +1,5 @@
contract C {
uint immutable public x = 1;
}
// ----
// x() -> 1
@@ -0,0 +1,17 @@
contract A {
uint immutable public x = 1;
uint public y;
constructor() public {
y = this.x();
}
}
contract C {
function f() public returns (bool) {
try new A() { return false; }
catch { return true; }
}
}
// ====
// EVMVersion: >=tangerineWhistle
// ----
// f() -> true