diff options
4 files changed, 24 insertions, 0 deletions
diff --git a/Changelog.md b/Changelog.md index aa2dce18..a957e928 100644 --- a/Changelog.md +++ b/Changelog.md @@ -79,6 +79,7 @@ Bugfixes: * Tests: Fix chain parameters to make ipc tests work with newer versions of cpp-ethereum. * Code Generator: Fix allocation of byte arrays (zeroed out too much memory). * Fix NatSpec json output for `@notice` and `@dev` tags on contract definitions. + * References Resolver: Do not crash on using ``_slot`` and ``_offset`` suffixes on their own. * References Resolver: Enforce ``storage`` as data location for mappings. * References Resolver: Report error instead of assertion fail when FunctionType has an undeclared type as parameter. * Type Checker: Disallow assignments to mappings within tuple assignments as well. diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index ba793933..5458c1b0 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -256,6 +256,11 @@ bool ReferencesResolver::visit(InlineAssembly const& _inlineAssembly) string("_slot").size() : string("_offset").size() )); + if (realName.empty()) + { + declarationError(_identifier.location, "In variable names _slot and _offset can only be used as a suffix."); + return size_t(-1); + } declarations = m_resolver.nameFromCurrentScope(realName); } if (declarations.size() != 1) diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_offset.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_offset.sol new file mode 100644 index 00000000..ec23a263 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_offset.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + assembly { + _offset + } + } +} +// ---- +// DeclarationError: (75-82): In variable names _slot and _offset can only be used as a suffix. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_slot.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_slot.sol new file mode 100644 index 00000000..d493a68a --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_slot.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + assembly { + _slot + } + } +} +// ---- +// DeclarationError: (75-80): In variable names _slot and _offset can only be used as a suffix. |