diff --git a/App/lib/Stub/StubGen/VpiReader.vp b/App/lib/Stub/StubGen/VpiReader.vp index 987c4cd..6397fbc 100644 --- a/App/lib/Stub/StubGen/VpiReader.vp +++ b/App/lib/Stub/StubGen/VpiReader.vp @@ -1526,7 +1526,22 @@ def _resolve_vpi_ret_annot_str(pool: memhub.MemBuddy*, while pos < buf_len and ret_annot[pos] == ' ': pos += 1 seg_start: sizet = pos - while pos < buf_len and ret_annot[pos] != '|': + # 只在**顶层**切 `|`:`[...]` 内的 `|` 属于泛型实参内部的联合注解,裸切会把首段 + # 截成 `list[ast.AST`(来自 `list[ast.AST | t.CPtr] | t.CPtr`),该段再经 + # strrchr('.') 落到 `AST` ⇒ 定义侧解析成 `AST*`(元素的指针),而正确答案是 + # list 专化结构的指针(至少也应落 i8* 通配)。深度计数按 `[`/`]`,与 + # _cache_vpi_param_annots_text 的顶层逗号切分同口径。 + depth_ra: int = 0 + while pos < buf_len: + ch_ra: char = ret_annot[pos] + if ch_ra == '[': + depth_ra += 1 + elif ch_ra == ']': + if depth_ra > 0: + depth_ra -= 1 + elif ch_ra == '|': + if depth_ra == 0: + break pos += 1 seg_end: sizet = pos # trim 尾随空格