refactor(tpv): Z 类兜底改 fail-fast(返回类型/模块级变量/枚举成员)

- ClassGenVTable 方法返回:有注解但解析失败即 fatal;State/CExport/CExtern 标记归一为 Void
- TranslatorGenMixin 模块级变量:有注解但解析失败即 fatal(保留无注解合法默认)
- ClassGenEnum._resolve_enum_member_type 4 处:Attribute 缺失名/Name 缺失 id/两处解析失败均改 fatal
  (无注解与 t.State 标记的 i32 默认保留)
This commit is contained in:
TermiNexus committed 2026-09-11 22:17:45 +08:00
1 parent cc3359faea
commit db8220801c
3 files changed
+35 -5

No files matched your search

+7
View File
@@ -731,6 +731,13 @@ class TranslatorGenMixin:
resolved_stg_ty = pointee_uv
resolved_stg_entry = gv_entry_u
var_ty = resolved
else:
# [S4 fail-fast] 模块级变量有注解但解析失败 → 不再静默用 i32
# (类型错 → 全局存储尺寸/字段访问/ABI 全错,静默错到运行期)。
# 若此处因「前向引用未注册类」触发,应收敛为多遍注册而非回退 i32。
self.Gen.TypeGenErr.fatal_error(
aa.annotation, f"模块级变量 '{var_name}' 类型注解解析失败", "NameError")
return 0
# 解析初始值(支持整数、负数字面量、列表字面量、字符串字面量)
if aa.value is not None:
val_kind: int = aa.value.kind()