Merge pull request #10350 from ethereum/fixStringLiteralAssignmentToStorage

[Sol->Yul] Fix string literal assignment to storage.
This commit is contained in:
chriseth 2020-11-19 16:06:06 +01:00 committed by GitHub
commit 8d315ee130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -241,6 +241,10 @@ void IRGeneratorForStatements::initializeStateVar(VariableDeclaration const& _va
return;
_varDecl.value()->accept(*this);
Type const* rightIntermediateType = _varDecl.value()->annotation().type->closestTemporaryType(_varDecl.type());
solAssert(rightIntermediateType, "");
IRVariable value = convert(*_varDecl.value(), *rightIntermediateType);
writeToLValue(
_varDecl.immutable() ?
IRLValue{*_varDecl.annotation().type, IRLValue::Immutable{&_varDecl}} :
@ -248,7 +252,7 @@ void IRGeneratorForStatements::initializeStateVar(VariableDeclaration const& _va
util::toCompactHexWithPrefix(m_context.storageLocationOfStateVariable(_varDecl).first),
m_context.storageLocationOfStateVariable(_varDecl).second
}},
*_varDecl.value()
value
);
}
catch (langutil::UnimplementedFeatureError const& _error)

View File

@ -5,5 +5,7 @@ contract C {
return data[0];
}
}
// ====
// compileViaYul: also
// ----
// f() -> "a"

View File

@ -8,5 +8,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x40, 0x80, 0x3, "ray", 0x2, "mi"