docs(tests): clarify compiler scenarios and capability helper ownership

This commit is contained in:
2026-11-15 19:54:49 +08:00
parent 4f6d2eec7f
commit 66f9e0764c
4 changed files with 23 additions and 13 deletions
+4
View File
@@ -325,6 +325,7 @@ fn declared_field_checks_cover_construction_inheritance_writes_and_gc() {
.unwrap();
vm.release(roots.object).unwrap();
vm.release(roots.type_type).unwrap();
// 一次模块声明建立继承字段、名义对象字段及未知注解三种约束,真正的构造/写入在后面分别触发。
execute(
&mut vm,
globals,
@@ -336,6 +337,7 @@ class Unknown { value: Missing }
"#,
ParseMode::Module,
);
// 每份交互源码只提交一条语句:先登记 Child 实例,再让 Holder 的字段持有同一实例。
// Interactive intentionally accepts one complete statement per source unit.
execute(
&mut vm,
@@ -381,6 +383,7 @@ class Unknown { value: Missing }
assert!(vm.del_attr(value, "count").is_err());
vm.set_attr(value, "count", Value::Number(10.into()))
.unwrap();
// 用同名新类替换全局 Base,旧 value 的名义类型图仍保留最初的 Base 身份。
execute(&mut vm, globals, "class Base {}", ParseMode::Interactive);
// 其他名义类型名称在声明环境中动态解析;Base 重定义后 Holder 的字段约束应按新身份检查。
// Other nominal names resolve dynamically in the declaring environment.
@@ -446,6 +449,7 @@ class Seed: Link {}
vm.set_attr(seed, "next", Value::Object(seed)).unwrap();
vm.dict_set(globals, Value::Text("old".into()), Value::Object(seed))
.unwrap();
// 新 Link 采用不同字段布局,只替换环境绑定;seed 及其 next 的原声明身份应不受影响。
execute(
&mut vm,
globals,