Merge pull request #10992 from ethereum/detectAssignToFunction

Detect assignment to function in inline assembly.
This commit is contained in:
Harikrishnan Mulackal 2021-02-23 13:26:45 +01:00 committed by GitHub
commit 148e1150f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View File

@ -530,11 +530,9 @@ void AsmAnalyzer::checkAssignment(Identifier const& _variable, YulString _valueT
bool found = false;
if (Scope::Identifier const* var = m_currentScope->lookup(_variable.name))
{
// Check that it is a variable.
// This can also hold a function, but that is caught by error 6041.
yulAssert(holds_alternative<Scope::Variable>(*var), "Assignment requires variable.");
if (!m_activeVariables.count(&std::get<Scope::Variable>(*var)))
if (!holds_alternative<Scope::Variable>(*var))
m_errorReporter.typeError(2657_error, _variable.location, "Assignment requires variable.");
else if (!m_activeVariables.count(&std::get<Scope::Variable>(*var)))
m_errorReporter.declarationError(
1133_error,
_variable.location,

View File

@ -0,0 +1,10 @@
contract C {
function f() public pure {
assembly {
function f() {}
f := 1
}
}
}
// ----
// TypeError 2657: (103-104): Assignment requires variable.