fix(TypeGenResolve): _class_true_def_sha1 只取 hex 段,修双点前缀 d1ed…461..AST*

GenApi.sha1_prefix_len 返回含末尾 "." 的 17(其文档写明),前一版按 17 拷贝 hex 段后再交 _concat_sha1_class 拼 ".",得到双点前缀 %"….d1ed020479454541..AST*" ⇒ parser.vp:3355 return scratch.children 处 coerce 报 CastError。改为按 17 判形、比对与拷贝都用 16(hex 段本身)。
This commit is contained in:
TermiNexus committed 2026-09-30 22:45:26 +08:00
1 parent 7b0c05b70b
commit 79f044bc47
1 file changed
+12 -5
+12 -5
View File
@@ -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,