aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp7
-rw-r--r--libsolidity/ast/ASTAnnotations.h2
2 files changed, 8 insertions, 1 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 7235b57a..e414e27c 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -1529,6 +1529,8 @@ bool TypeChecker::visit(Identifier const& _identifier)
!!annotation.referencedDeclaration,
"Referenced declaration is null after overload resolution."
);
+ auto variableDeclaration = dynamic_cast<VariableDeclaration const*>(annotation.referencedDeclaration);
+ annotation.isConstant = variableDeclaration != nullptr && variableDeclaration->isConstant();
annotation.isLValue = annotation.referencedDeclaration->isLValue();
annotation.type = annotation.referencedDeclaration->type();
if (!annotation.type)
@@ -1612,7 +1614,10 @@ void TypeChecker::requireLValue(Expression const& _expression)
{
_expression.annotation().lValueRequested = true;
_expression.accept(*this);
- if (!_expression.annotation().isLValue)
+
+ if (_expression.annotation().isConstant)
+ typeError(_expression.location(), "Cannot assign to a constant variable.");
+ else if (!_expression.annotation().isLValue)
typeError(_expression.location(), "Expression has to be an lvalue.");
}
diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h
index 768e56db..9c4c3ae8 100644
--- a/libsolidity/ast/ASTAnnotations.h
+++ b/libsolidity/ast/ASTAnnotations.h
@@ -154,6 +154,8 @@ struct ExpressionAnnotation: ASTAnnotation
{
/// Inferred type of the expression.
TypePointer type;
+ /// Whether the expression is a constant variable
+ bool isConstant = false;
/// Whether it is an LValue (i.e. something that can be assigned to).
bool isLValue = false;
/// Whether the expression is used in a context where the LValue is actually required.
lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/security/hs-x509-system?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=f84f90dc28e919d64b4c426d0e00e337a41d9f86'>Mark almost all Haskell ports for expiration by mid Apriltcberner2019-03-311-0/+3 * lang/ghc: Update to 8.6.3 and bump PORTREVISION's of all Haskell ports.arrowd2019-01-061-1/+1 * lang/ghc: Update to 8.4.3 and bump PORTREVISION's of all Haskell ports.arrowd2018-06-301-0/+1 * Update lang/ghc 8.4.2 and the hs-* ports the newer versionstcberner2018-05-262-5/+4 * Switch C compiler used to compile GHC to base Clang.tcberner2018-02-101-0/+1 * - Update The Glorious Glasgow Haskell Compiler to version 8.0.2tcberner2017-08-092-3/+4 * http://github.com redirects to https://github.com, spare everyone a redirect.mat2016-12-021-1/+1