Parsing of immutable state variable.

This commit is contained in:
chriseth
2020-03-12 17:11:24 +01:00
parent f8f18f2e55
commit fa148f2483
17 changed files with 84 additions and 12 deletions
@@ -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".