diff --git a/App/lib/core/Gen/Class/ClassGenDef.vp b/App/lib/core/Gen/Class/ClassGenDef.vp index 901bae6..0b9c6df 100644 --- a/App/lib/core/Gen/Class/ClassGenDef.vp +++ b/App/lib/core/Gen/Class/ClassGenDef.vp @@ -113,7 +113,16 @@ novirtual class ClassGenDef(ClassGenBase.ClassGenBase): on_copy: str = CompilerFactory.factory.PermPool.alloc(on_len + 1) if on_copy is not None: string.strcpy(on_copy, old_name) - *existing.Ty = llvmlite.LLVMType.Struct(llvmlite.get_struct_fields(existing.Ty), llvmlite.get_struct_fcount(existing.Ty), on_copy) + # in-place 覆盖所指 REnum 值(保留 existing.Ty 的指针同一性: + # Phase A 已把它登记进 named-type 表,换指针旧条目仍指向悬空 + # Name)。REnum 变体构造返回 **boxed 指针**(见 + # includes/llvmlite/__types.vp:185-196 的同款写法与 + # __builder.vp:173 `result_ty: rawptr[LLVMType] = + # LLVMType.Ptr(ty)`),所以不能用 `*existing.Ty = <构造>` + # 直接赋值(指针→值,严格规则禁止);按仓库既定 idiom 用 + # c.DerefAs(ptr, ) 做**整对象物化** + # (HandlesExprCall._HandleCDerefAsLlvm 的"整对象拷贝"分支)。 + c.DerefAs(existing.Ty, llvmlite.LLVMType.Struct(llvmlite.get_struct_fields(existing.Ty), llvmlite.get_struct_fcount(existing.Ty), on_copy)) # Phase B: 将已存在的命名结构体注册到当前模块(输出类型定义行) llvmlite.module_add_named_type(trans.Module, pool, existing.Ty) # B5:existing 路径(Phase B 已注册类)同样需设置 packed/aligned——