Merge pull request #7570 from HenryRLee/issue4575

Treat super as an unknown identifier in inline assembly #4575
This commit is contained in:
chriseth 2019-10-28 11:43:32 +01:00 committed by GitHub
commit 9eb08c0cbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View File

@ -10,6 +10,7 @@ Compiler Features:
Bugfixes:
* Type Checker: Disallow constructor of the same class to be used as modifier
* Code Generator: Fixed a faulty assert that would wrongly trigger for array sizes exceeding unsigned integer
* Type Checker: Treat magic variables as unknown identifiers in inline assembly

View File

@ -702,6 +702,9 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
}
else if (_context == yul::IdentifierContext::LValue)
{
if (dynamic_cast<MagicVariableDeclaration const*>(declaration))
return size_t(-1);
m_errorReporter.typeError(_identifier.location, "Only local variables can be assigned to in inline assembly.");
return size_t(-1);
}

View File

@ -2,12 +2,18 @@ contract C {
function f() public {
assembly {
super := 1
this := 1
msg := 1
block := 1
f := 1
C := 1
}
}
}
// ----
// TypeError: (58-63): Only local variables can be assigned to in inline assembly.
// TypeError: (75-76): Only local variables can be assigned to in inline assembly.
// TypeError: (88-89): Only local variables can be assigned to in inline assembly.
// DeclarationError: (58-63): Variable not found or variable not lvalue.
// DeclarationError: (75-79): Variable not found or variable not lvalue.
// DeclarationError: (91-94): Variable not found or variable not lvalue.
// DeclarationError: (106-111): Variable not found or variable not lvalue.
// TypeError: (123-124): Only local variables can be assigned to in inline assembly.
// TypeError: (136-137): Only local variables can be assigned to in inline assembly.