aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-08-07 20:17:56 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-08-07 20:18:54 +0800
commit05cc7e79e1bf484c71ce93510fbfbf2c3e415cc6 (patch)
tree795453abee9aa819951ee8a532de623d8719a648 /libsolidity/analysis
parenteb7b3862ac5089615710d07c9a56b8edc0472394 (diff)
downloaddexon-solidity-05cc7e79e1bf484c71ce93510fbfbf2c3e415cc6.tar.gz
dexon-solidity-05cc7e79e1bf484c71ce93510fbfbf2c3e415cc6.tar.zst
dexon-solidity-05cc7e79e1bf484c71ce93510fbfbf2c3e415cc6.zip
More precise error message if using non-variables with _slot/_offset
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/ReferencesResolver.cpp2
-rw-r--r--libsolidity/analysis/TypeChecker.cpp8
2 files changed, 7 insertions, 3 deletions
diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp
index b888ecd6..5458c1b0 100644
--- a/libsolidity/analysis/ReferencesResolver.cpp
+++ b/libsolidity/analysis/ReferencesResolver.cpp
@@ -262,8 +262,6 @@ bool ReferencesResolver::visit(InlineAssembly const& _inlineAssembly)
return size_t(-1);
}
declarations = m_resolver.nameFromCurrentScope(realName);
- if (!dynamic_cast<VariableDeclaration const*>(declarations.front()))
- return size_t(-1);
}
if (declarations.size() != 1)
return size_t(-1);
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 7cec7c43..d98d6af1 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -867,6 +867,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
return size_t(-1);
Declaration const* declaration = ref->second.declaration;
solAssert(!!declaration, "");
+ bool requiresStorage = ref->second.isSlot || ref->second.isOffset;
if (auto var = dynamic_cast<VariableDeclaration const*>(declaration))
{
if (var->isConstant())
@@ -874,7 +875,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
m_errorReporter.typeError(_identifier.location, "Constant variables not supported by inline assembly.");
return size_t(-1);
}
- else if (ref->second.isSlot || ref->second.isOffset)
+ else if (requiresStorage)
{
if (!var->isStateVariable() && !var->type()->dataStoredIn(DataLocation::Storage))
{
@@ -906,6 +907,11 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
return size_t(-1);
}
}
+ else if (requiresStorage)
+ {
+ m_errorReporter.typeError(_identifier.location, "The suffixes _offset and _slot can only be used on storage variables.");
+ return size_t(-1);
+ }
else if (_context == julia::IdentifierContext::LValue)
{
m_errorReporter.typeError(_identifier.location, "Only local variables can be assigned to in inline assembly.");