fix(structgen): 裸名回退字段未找到时返回 None 而非 fatal_error,让 REnum 变体别名回退生效
- ce62546 新增的裸名回退分支在类命中但字段未找到时 fatal_error,
截断了 ExprGenAttr L853-864 的 REnum 变体别名回退(LLVMType.Pointee
→ _p2 槽位是变体别名非普通字段)→ AssignGenMixin.vp:1002
"类 llvmlite.LLVMType 裸名回退但字段 Pointee 未找到"
- 改为字段未找到 return None,对齐主 SHA1 匹配分支语义,让调用方
有机会走 REnum 别名/继承链回退
This commit is contained in:
1 parent
ce62546e90
commit
c542442987
1 file changed
+5
-6
@@ -854,12 +854,11 @@ class StructGenMixin:
|
||||
if string.strcmp(fe_q2.Name, field_name) == 0:
|
||||
stdlib.free(mod_buf_q)
|
||||
return fe_q2
|
||||
# 裸名类命中但字段未找到:可读化报错
|
||||
viperlib.snprintf(fb, 1024,
|
||||
"lookup_field_by_class: 类 '%s' 裸名回退"
|
||||
"(ModuleSha1=%s, FieldCount=%d)但字段 '%s' 未找到",
|
||||
class_name, mod_sha1_q, same_entry_q.FieldCount, field_name)
|
||||
self.Gen.TypeGenErr.fatal_error(node, fb, "AttributeError")
|
||||
# 裸名类命中但字段未找到:返回 None(不 fatal_error)——
|
||||
# 字段可能是 REnum 变体别名(如 LLVMType.Pointee → _p2
|
||||
# 槽位)或继承字段,调用方(ExprGenAttr L853-864)有
|
||||
# REnum 别名回退等后续机会;对齐主 SHA1 匹配分支
|
||||
# (L797-798 字段未找到 return None)的语义。
|
||||
stdlib.free(mod_buf_q)
|
||||
return None
|
||||
# 裸名也不唯一/不存在:fail-fast(暴露 vpi 注入/注册缺陷,
|
||||
|
||||
Reference in new issue
Block a user