mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Constants are considered pure.
This commit is contained in:
parent
d3647b13e4
commit
c8772a54c3
@ -30,6 +30,7 @@ Compiler Features:
|
||||
Bugfixes:
|
||||
* NatSpec: Constructors and functions have consistent userdoc output.
|
||||
* Inheritance: Disallow public state variables overwriting ``pure`` functions.
|
||||
* State Mutability: Constant public state variables are considered ``pure`` functions.
|
||||
|
||||
|
||||
### 0.6.12 (unreleased)
|
||||
|
@ -289,7 +289,7 @@ StateMutability OverrideProxy::stateMutability() const
|
||||
return std::visit(GenericVisitor{
|
||||
[&](FunctionDefinition const* _item) { return _item->stateMutability(); },
|
||||
[&](ModifierDefinition const*) { solAssert(false, "Requested state mutability from modifier."); return StateMutability{}; },
|
||||
[&](VariableDeclaration const*) { return StateMutability::View; }
|
||||
[&](VariableDeclaration const* _var) { return _var->isConstant() ? StateMutability::Pure : StateMutability::View; }
|
||||
}, m_item);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,7 @@
|
||||
abstract contract C {
|
||||
function foo() external pure virtual returns (uint);
|
||||
}
|
||||
contract X is C {
|
||||
uint public constant override foo = 7;
|
||||
}
|
||||
// ----
|
@ -0,0 +1,8 @@
|
||||
abstract contract C {
|
||||
function foo() external pure virtual returns (uint);
|
||||
}
|
||||
contract X is C {
|
||||
uint public immutable override foo = 7;
|
||||
}
|
||||
// ----
|
||||
// TypeError 6959: (100-124): Overriding public state variable changes state mutability from "pure" to "view".
|
Loading…
Reference in New Issue
Block a user