mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Accessors for immutable variables.
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user