From 87b24c2445341f85c78d1f1cdd9829e78c8115cc Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Mon, 5 Oct 2026 14:14:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(type):=20resolve=5Ftypedef=5For=5Fmap=20?= =?UTF-8?q?=E8=A1=A5=E9=BD=90=E8=A3=B8=E5=86=85=E5=BB=BA=E5=88=AB=E5=90=8D?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=20int(x,=20t.CPtr)=20=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 裸名 str/bytes/int/char/bool/float/double/void 在 map_t_type 中只有 t.CXXX 拼写,导致 _tc_h4 的双参指针包装分支拿不到 bare_ty,落回外部函数返回类型兜底并 fail-fast(argparse.vp:93 c.Deref(int(uint64(ptr), t.CPtr)) 报 TypeError: int)。 --- App/lib/core/Gen/Type/TypeGenResolve.vp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/App/lib/core/Gen/Type/TypeGenResolve.vp b/App/lib/core/Gen/Type/TypeGenResolve.vp index dc62e16..a8cc4c8 100644 --- a/App/lib/core/Gen/Type/TypeGenResolve.vp +++ b/App/lib/core/Gen/Type/TypeGenResolve.vp @@ -840,6 +840,17 @@ novirtual class TypeGenResolve(TypeGenBase.TypeGenBase): lib_ty: mlirlite.LLVMType* = self.resolve_annotation_type(pool, lib_node, imported_modules, from_imports, trans, 1) self.Gen.TypeGenCType.CTypedefResolveDepth -= 1 if lib_ty is not None: return lib_ty + # Bare Python/C builtin aliases: map_t_type only knows the t.CXxx spelling, so + # resolve them here to match resolve_annotation_type's bare-name branch. Without + # this the two-arg form int(x, t.CPtr) misses _tc_h4 and fails fast as "int". + if string.strcmp(name, "str") == 0: return mlirlite.Ptr(pool, mlirlite.Int8(pool)) + if string.strcmp(name, "bytes") == 0: return mlirlite.Ptr(pool, mlirlite.Int8(pool)) + if string.strcmp(name, "int") == 0: return mlirlite.Int32(pool) + if string.strcmp(name, "char") == 0: return mlirlite.Int8(pool) + if string.strcmp(name, "bool") == 0: return mlirlite.Int1(pool) + if string.strcmp(name, "float") == 0: return mlirlite.Float(pool) + if string.strcmp(name, "double") == 0: return mlirlite.Double(pool) + if string.strcmp(name, "void") == 0: return mlirlite.Void(pool) return self.map_t_type(pool, name) def get_type_size_bytes(self, pool: memhub.MemBuddy*, name: str, imported_modules: str, from_imports: str) -> int: """Return the type size in bytes via resolve_typedef_or_map, or 0 on failure."""