diff --git a/App/lib/core/Gen/Type/TypeGenResolve.vp b/App/lib/core/Gen/Type/TypeGenResolve.vp index 3927881..9c8382f 100644 --- a/App/lib/core/Gen/Type/TypeGenResolve.vp +++ b/App/lib/core/Gen/Type/TypeGenResolve.vp @@ -770,6 +770,28 @@ novirtual class TypeGenResolve(TypeGenBase.TypeGenBase): res_c: str = self._concat_sha1_class(pool, sha1c, type_name) if res_c is not None: return res_c + # ---- 5.2 裸名来自内建模块 t/c ⇒ 统一为 "t.X" / "c.X" ---- + # 依据:内建伪模块 t/c **没有模块 SHA1**(规则 5 的"模块名 → sha1"表查不到), + # 于是 `from t import CPtr` 之后写的**裸名** `CPtr` 会原样保留,而规则 3 保留的是 + # `t.CPtr` ⇒ 同一类型两种票名(`list[CPtr]` vs `list[t.CPtr]` 分裂成两个特化体), + # 并额外刷一条 ERROR [类型实参归属](现场 Test/NewAstTest/App/main.vp 的裸名 + # 'CPtr',log 里 from_imports 明写 `CPtr:t`)。 + # 规范形取 "t.X"/"c.X"(规则 3 已定的形式),使两种写法同票名。 + # 只对"本名就是 t/c 的**已知内建类型名**"生效(map_t_type 命中):别名写法 + # (`from t import CPtr as P`)不猜真实符号名,维持原样,避免产出错票名。 + if from_imports is not None: + _bi_mod: str = self.Gen.ImportsGen.lookup_from_import(from_imports, type_name, 0) + if _bi_mod is not None: + if (string.strcmp(_bi_mod, "t") == 0 or string.strcmp(_bi_mod, "c") == 0) \ + and self.map_t_type(pool, type_name) is not None: + _bi_len: sizet = string.strlen(_bi_mod) + 1 + string.strlen(type_name) + 1 + _bi_buf: str = pool.alloc(_bi_len) + if _bi_buf is not None: + _bi_buf[0] = '\0' + string.strcat(_bi_buf, _bi_mod) + string.strcat(_bi_buf, ".") + string.strcat(_bi_buf, type_name) + return _bi_buf # ---- 5.5 裸名且是已注册类:加**定义模块 SHA1** 前缀 ---- # 规则 5 只查 from_imports(可见性表):**本模块自己声明的类**不在表内 ⇒ # 原样返回裸名 ⇒ 同一类型"本模块内是 list[rawptr[AST]]、被引用模块里是