mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6043 from ethereum/asm-jump-invalidlabel
Proper error message for missing variables in inline assembly
This commit is contained in:
commit
0613c69c4a
@ -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.
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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.
|
@ -0,0 +1,9 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
assembly {
|
||||
x := 1
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (63-64): Variable not found or variable not lvalue.
|
Loading…
Reference in New Issue
Block a user