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,