iter 22b.2.7: fix — cycle termination guard, hoist type_repr

This commit is contained in:
2026-05-09 18:23:52 +02:00
parent ae7281ac41
commit 6869bd5d0c
+8 -1
View File
@@ -575,15 +575,22 @@ fn build_registry(
// step at the same type-hash.
for (key, entry) in entries.iter() {
let (class_name, type_hash) = key;
let type_repr = type_head_name(&entry.instance.type_);
// Iter 22b.2 leaves superclass-cycle detection to a future arm;
// here we just terminate the walk.
let mut visited: BTreeSet<&str> = BTreeSet::new();
let mut current = class_by_name.get(class_name.as_str()).copied();
while let Some(c) = current {
if !visited.insert(c.name.as_str()) {
break;
}
if let Some(sc) = &c.superclass {
let sc_key = (sc.class.clone(), type_hash.clone());
if !entries.contains_key(&sc_key) {
return Err(WorkspaceLoadError::MissingSuperclassInstance {
class: class_name.clone(),
superclass: sc.class.clone(),
type_repr: type_head_name(&entry.instance.type_),
type_repr: type_repr.clone(),
});
}
current = class_by_name.get(sc.class.as_str()).copied();