Fix accessing constants at file level from inline assembly.

This commit is contained in:
chriseth 2021-01-14 10:51:33 +01:00
parent fe344ed6e5
commit 30305ebbd9
2 changed files with 6 additions and 8 deletions

View File

@ -111,19 +111,15 @@ private:
solUnimplementedAssert(varDecl, ""); solUnimplementedAssert(varDecl, "");
string const& suffix = reference.suffix; string const& suffix = reference.suffix;
if (suffix.empty() && !varDecl->isStateVariable()) string value;
if (suffix.empty() && varDecl->isLocalVariable())
{ {
auto const& var = m_context.localVariable(*varDecl); auto const& var = m_context.localVariable(*varDecl);
solAssert(var.type().sizeOnStack() == 1, ""); solAssert(var.type().sizeOnStack() == 1, "");
return yul::Identifier{ value = var.commaSeparatedList();
_identifier.location,
yul::YulString{var.commaSeparatedList()}
};
} }
else if (varDecl->isConstant())
string value;
if (varDecl->isConstant())
{ {
VariableDeclaration const* variable = rootConstVariableDeclaration(*varDecl); VariableDeclaration const* variable = rootConstVariableDeclaration(*varDecl);
solAssert(variable, ""); solAssert(variable, "");

View File

@ -5,5 +5,7 @@ contract C {
assembly { z := e } assembly { z := e }
} }
} }
// ====
// compileViaYul: also
// ---- // ----
// f() -> 0x1212121212121212121212121000002134593163 // f() -> 0x1212121212121212121212121000002134593163