mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Parsing of immutable state variable.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
function f(uint immutable) public pure {}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (28-42): The "immutable" keyword can only be used for state variables.
|
||||
@@ -0,0 +1,11 @@
|
||||
contract C {
|
||||
uint immutable x;
|
||||
function f() public view {
|
||||
uint t;
|
||||
assembly {
|
||||
t := x
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (118-119): Assembly access to immutable variables is not supported.
|
||||
@@ -0,0 +1,7 @@
|
||||
contract C {
|
||||
uint immutable immutable x;
|
||||
uint immutable constant x;
|
||||
}
|
||||
// ----
|
||||
// ParserError: (32-41): Constantness already set to "immutable"
|
||||
// ParserError: (64-72): Constantness already set to "immutable"
|
||||
@@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
uint immutable public x;
|
||||
}
|
||||
// ----
|
||||
// UnimplementedFeatureError: NONE
|
||||
@@ -0,0 +1,3 @@
|
||||
contract C {
|
||||
uint immutable x;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
uint[] immutable x;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (17-35): Immutable variables cannot have a non-value type.
|
||||
@@ -0,0 +1,8 @@
|
||||
contract B {
|
||||
uint immutable x;
|
||||
function f() public pure returns (uint) {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (96-97): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
Reference in New Issue
Block a user