mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10992 from ethereum/detectAssignToFunction
Detect assignment to function in inline assembly.
This commit is contained in:
commit
148e1150f2
@ -530,11 +530,9 @@ void AsmAnalyzer::checkAssignment(Identifier const& _variable, YulString _valueT
|
|||||||
bool found = false;
|
bool found = false;
|
||||||
if (Scope::Identifier const* var = m_currentScope->lookup(_variable.name))
|
if (Scope::Identifier const* var = m_currentScope->lookup(_variable.name))
|
||||||
{
|
{
|
||||||
// Check that it is a variable.
|
if (!holds_alternative<Scope::Variable>(*var))
|
||||||
// This can also hold a function, but that is caught by error 6041.
|
m_errorReporter.typeError(2657_error, _variable.location, "Assignment requires variable.");
|
||||||
yulAssert(holds_alternative<Scope::Variable>(*var), "Assignment requires variable.");
|
else if (!m_activeVariables.count(&std::get<Scope::Variable>(*var)))
|
||||||
|
|
||||||
if (!m_activeVariables.count(&std::get<Scope::Variable>(*var)))
|
|
||||||
m_errorReporter.declarationError(
|
m_errorReporter.declarationError(
|
||||||
1133_error,
|
1133_error,
|
||||||
_variable.location,
|
_variable.location,
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
assembly {
|
||||||
|
function f() {}
|
||||||
|
f := 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 2657: (103-104): Assignment requires variable.
|
Loading…
Reference in New Issue
Block a user