Fix get_attr_lazy

I had misunderstood/misused the ? suffix operator for the Option type.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2024-09-23 21:48:44 -07:00
parent 9c4898ff8d
commit fe586526df

View File

@@ -256,6 +256,7 @@ pub trait Obj: Debug + Display + Any + Trace {
let mut type_inst = self.type_inst();
loop {
let vtable_entry =
with_obj_downcast_mut(type_inst.clone(), |type_inst: &mut TypeInst| {
type_inst.vtable.get(name).cloned()
})
@@ -269,7 +270,10 @@ pub trait Obj: Debug + Display + Any + Trace {
};
self.set_attr(name, ptr.clone());
ptr
})?;
});
if vtable_entry.is_some() {
return vtable_entry;
}
let type_inst_copy = type_inst.borrow().type_inst();
if type_inst.borrow().equals(&*type_inst_copy.borrow()) {
return None;
@@ -1158,6 +1162,7 @@ fn test_obj_equals() {
assert!(obj2.borrow().equals(&*obj1.borrow()));
}
#[test]
fn test_obj_vtable() {
let mut builtins = HashMap::new();
init_types(&mut builtins);