Fix missing assignment to me_value found by msan. (#3019)

Looks like a small oversight in #2946. Probably missed because type
access shouldn't really access the me_value.
This commit is contained in:
Jon Ross-Perkins
2023-07-24 22:31:39 +00:00
committed by GitHub
parent cf2ddc6072
commit a3d52b089d
3 changed files with 7 additions and 7 deletions
+5 -5
View File
@@ -173,7 +173,7 @@ static auto GetPositionalElement(Nonnull<const TupleValue*> tuple,
static auto GetNamedElement(Nonnull<Arena*> arena, Nonnull<const Value*> v,
const ElementPath::Component& field,
SourceLocation source_loc,
Nonnull<const Value*> me_value)
std::optional<Nonnull<const Value*>> me_value)
-> ErrorOr<Nonnull<const Value*>> {
CARBON_CHECK(field.element()->kind() == ElementKind::NamedElement)
<< "Invalid element, expecting NamedElement";
@@ -199,7 +199,7 @@ static auto GetNamedElement(Nonnull<Arena*> arena, Nonnull<const Value*> v,
mem_decl.has_value()) {
const auto& fun_decl = cast<FunctionDeclaration>(**mem_decl);
if (fun_decl.is_method()) {
return arena->New<BoundMethodValue>(&fun_decl, me_value,
return arena->New<BoundMethodValue>(&fun_decl, *me_value,
&impl_witness->bindings());
} else {
// Class function.
@@ -243,7 +243,7 @@ static auto GetNamedElement(Nonnull<Arena*> arena, Nonnull<const Value*> v,
// Found a method. Turn it into a bound method.
const auto& m = cast<FunctionValue>(**func);
if (m.declaration().virt_override() == VirtualOverride::None) {
return arena->New<BoundMethodValue>(&m.declaration(), me_value,
return arena->New<BoundMethodValue>(&m.declaration(), *me_value,
&class_type.bindings());
}
// Method is virtual, get child-most class value and perform vtable
@@ -306,7 +306,7 @@ static auto GetNamedElement(Nonnull<Arena*> arena, Nonnull<const Value*> v,
static auto GetElement(Nonnull<Arena*> arena, Nonnull<const Value*> v,
const ElementPath::Component& path_comp,
SourceLocation source_loc,
Nonnull<const Value*> me_value)
std::optional<Nonnull<const Value*>> me_value)
-> ErrorOr<Nonnull<const Value*>> {
switch (path_comp.element()->kind()) {
case ElementKind::NamedElement:
@@ -335,7 +335,7 @@ static auto GetElement(Nonnull<Arena*> arena, Nonnull<const Value*> v,
auto Value::GetElement(Nonnull<Arena*> arena, const ElementPath& path,
SourceLocation source_loc,
Nonnull<const Value*> me_value) const
std::optional<Nonnull<const Value*>> me_value) const
-> ErrorOr<Nonnull<const Value*>> {
Nonnull<const Value*> value(this);
for (const ElementPath::Component& field : path.components_) {