Merge pull request #6043 from ethereum/asm-jump-invalidlabel

Proper error message for missing variables in inline assembly
This commit is contained in:
chriseth 2019-02-20 14:32:40 +01:00 committed by GitHub
commit 0613c69c4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 1 deletions

View File

@ -12,6 +12,7 @@ Bugfixes:
* ABIEncoderV2: Fix internal error related to bare delegatecall.
* ABIEncoderV2: Fix internal error related to ecrecover.
* ABIEncoderV2: Fix internal error related to mappings as library parameters.
* Inline Assembly: Proper error message for missing variables.
* SMTChecker: Fixed crash when used with fixed-sized arrays.
* Yul: Properly detect name clashes with functions before their declaration.

View File

@ -298,11 +298,13 @@ bool ReferencesResolver::visit(InlineAssembly const& _inlineAssembly)
}
declarations = m_resolver.nameFromCurrentScope(realName);
}
if (declarations.size() != 1)
if (declarations.size() > 1)
{
declarationError(_identifier.location, "Multiple matching identifiers. Resolving overloaded identifiers is not supported.");
return size_t(-1);
}
else if (declarations.size() == 0)
return size_t(-1);
if (auto var = dynamic_cast<VariableDeclaration const*>(declarations.front()))
if (var->isLocalVariable() && _crossesFunctionBoundary)
{

View File

@ -0,0 +1,10 @@
contract C {
function f() public pure {
assembly {
jump(xy)
}
}
}
// ----
// DeclarationError: (68-70): Identifier not found.
// SyntaxError: (63-71): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.

View File

@ -0,0 +1,9 @@
contract C {
function f() public pure {
assembly {
x := 1
}
}
}
// ----
// DeclarationError: (63-64): Variable not found or variable not lvalue.