aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-10-04 00:58:12 +0800
committerGitHub <noreply@github.com>2017-10-04 00:58:12 +0800
commitcfc4e5dde30daf63fdc78faa0e863965e167aff9 (patch)
tree7966106164c51f392f497057028160d6193e6409 /libsolidity
parent5c284589202c261c06dadfe7a598cc23752e8e48 (diff)
parent2b8235269221cacbcf9beb793d969c451b1927a3 (diff)
downloaddexon-solidity-cfc4e5dde30daf63fdc78faa0e863965e167aff9.tar.gz
dexon-solidity-cfc4e5dde30daf63fdc78faa0e863965e167aff9.tar.zst
dexon-solidity-cfc4e5dde30daf63fdc78faa0e863965e167aff9.zip
Merge pull request #2542 from federicobond/disallow-non-pure-constant
Disallow non-pure constant state variables (0.5.0)
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index d45e9e89..b2a88059 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -645,14 +645,23 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
if (!allowed)
m_errorReporter.typeError(_variable.location(), "Constants of non-value type not yet implemented.");
}
+
if (!_variable.value())
m_errorReporter.typeError(_variable.location(), "Uninitialized \"constant\" variable.");
else if (!_variable.value()->annotation().isPure)
- m_errorReporter.warning(
- _variable.value()->location(),
- "Initial value for constant variable has to be compile-time constant. "
- "This will fail to compile with the next breaking version change."
- );
+ {
+ if (_variable.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050))
+ m_errorReporter.typeError(
+ _variable.value()->location(),
+ "Initial value for constant variable has to be compile-time constant."
+ );
+ else
+ m_errorReporter.warning(
+ _variable.value()->location(),
+ "Initial value for constant variable has to be compile-time constant. "
+ "This will fail to compile with the next breaking version change."
+ );
+ }
}
if (!_variable.isStateVariable())
{