diff --git a/App/lib/core/Gen/Expr/ExprGenBase.vp b/App/lib/core/Gen/Expr/ExprGenBase.vp index 0de14fc..7e758aa 100644 --- a/App/lib/core/Gen/Expr/ExprGenBase.vp +++ b/App/lib/core/Gen/Expr/ExprGenBase.vp @@ -705,16 +705,21 @@ novirtual class ExprGenBase: # 覆盖 `*槽 = `。否则该写法会被「指针 → 非基本类型值」禁令拦下 # (现场 ClassGenDef.vp:128 `*existing.Ty = llvmlite.LLVMType.Struct(...)`)。 if cl.func.kind() == ast.ASTKind.Attribute: - base_v: ast.AST* = (ast.Attribute*(cl.func)).value - # 取属性链最右的裸名(llvmlite.LLVMType → LLVMType) - while base_v is not None and base_v.kind() == ast.ASTKind.Attribute: - base_v = (ast.Attribute*(base_v)).value - if base_v is not None and base_v.kind() == ast.ASTKind.Name: - base_nm: str = (ast.Name*(base_v)).id - if base_nm is not None and self.Gen.ClassGenEnum._is_renum_class_name(base_nm) != 0: - rn_ent: GenTypes.StructEntry* = self.Gen.StructGen.find_struct(base_nm) - if rn_ent is not None and rn_ent.Ty is not None: - return rn_ent.Ty + # 取「变体名左边那一段」作为枚举类名:被调方形如 `<限定链>.<变体>`, + # EnumType.Variant → 限定段是裸名 EnumType + # llvmlite.LLVMType.Struct → 限定段是属性 LLVMType(**不是**链根 + # llvmlite,早期实现走到链根导致漏判) + qual: ast.AST* = (ast.Attribute*(cl.func)).value + base_nm: str = None + if qual is not None: + if qual.kind() == ast.ASTKind.Attribute: + base_nm = (ast.Attribute*(qual)).attr + elif qual.kind() == ast.ASTKind.Name: + base_nm = (ast.Name*(qual)).id + if base_nm is not None and self.Gen.ClassGenEnum._is_renum_class_name(base_nm) != 0: + rn_ent: GenTypes.StructEntry* = self.Gen.StructGen.find_struct(base_nm) + if rn_ent is not None and rn_ent.Ty is not None: + return rn_ent.Ty return None # ============================================================ # _same_agg_ty - 两个聚合类型是否为「同一非基本类型」(构造物化豁免的类型匹配)