From 79f044bc47a27c37cd3efd847be2ccf90f587418 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Wed, 30 Sep 2026 22:45:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(TypeGenResolve):=20=5Fclass=5Ftrue=5Fdef=5F?= =?UTF-8?q?sha1=20=E5=8F=AA=E5=8F=96=20hex=20=E6=AE=B5=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=8F=8C=E7=82=B9=E5=89=8D=E7=BC=80=20d1ed=E2=80=A6461..AST*?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GenApi.sha1_prefix_len 返回含末尾 "." 的 17(其文档写明),前一版按 17 拷贝 hex 段后再交 _concat_sha1_class 拼 ".",得到双点前缀 %"….d1ed020479454541..AST*" ⇒ parser.vp:3355 return scratch.children 处 coerce 报 CastError。改为按 17 判形、比对与拷贝都用 16(hex 段本身)。 --- App/lib/core/Gen/Type/TypeGenResolve.vp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/App/lib/core/Gen/Type/TypeGenResolve.vp b/App/lib/core/Gen/Type/TypeGenResolve.vp index f587a73..3927881 100644 --- a/App/lib/core/Gen/Type/TypeGenResolve.vp +++ b/App/lib/core/Gen/Type/TypeGenResolve.vp @@ -260,17 +260,24 @@ novirtual class TypeGenResolve(TypeGenBase.TypeGenBase): nm: str = llvmlite.get_struct_name(e.Ty) if nm is None: return cand_sha1 + # GenApi.sha1_prefix_len 返回的是**含末尾 '.' 的前缀字节数 17**(见其文档), + # 本函数只要 hex 段本身(16)—— 直接拷 17 再交 _concat_sha1_class 拼 '.' + # 会得到双点 `d1ed020479454541..AST*`(现场 parser.vp:3355 的 CastError 根因)。 pf: int = GenApi.sha1_prefix_len(nm) - # 前缀长度异常(无前缀 / 非 "16hex." 形)⇒ 不表态 if pf <= 1 or pf >= 32: return cand_sha1 - if string.strncmp(nm, cand_sha1, sizet(pf)) == 0: + hexn: int = pf + if nm[sizet(hexn) - 1] == '.': + hexn -= 1 + if hexn <= 0: return cand_sha1 - b: str = pool.alloc(sizet(pf) + 1) + if string.strncmp(nm, cand_sha1, sizet(hexn)) == 0: + return cand_sha1 + b: str = pool.alloc(sizet(hexn) + 1) if b is None: return cand_sha1 - string.strncpy(b, nm, sizet(pf)) - b[sizet(pf)] = '\0' + string.strncpy(b, nm, sizet(hexn)) + b[sizet(hexn)] = '\0' return b def _repl_opaque_class_ty(self, pool: memhub.MemBuddy*, mod_sha1: str,