From 3645d00753a560215ff71ae795cb2194449f6dff Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Thu, 1 Oct 2026 18:01:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(FormatStringTest):=20ptr=5Fvar=20=E6=B3=A8?= =?UTF-8?q?=E8=A7=A3=E6=94=B9=E4=B8=BA=20str=20|=20t.CPtr=EF=BC=8C?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=20c.Addr(s)=20=E7=9A=84=E5=AE=9E=E9=99=85?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=20i8**?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit c.Addr(s) 取的是局部变量 s(str = i8*)的地址,结果是 i8**;与 INTPTR(= t.CInt | t.CPtr,int*,见 includes/stdint.vp) 层数与基座都不同,指针隐式转换收紧后(层数必须相同)原写法报 CastError。 --- FormatStringTest/App/main.vp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FormatStringTest/App/main.vp b/FormatStringTest/App/main.vp index 0af881a..9e50ccf 100644 --- a/FormatStringTest/App/main.vp +++ b/FormatStringTest/App/main.vp @@ -37,7 +37,10 @@ def main() -> int: print("Assigned: ", s) # ctraits.isptr 编译时类型判断测试 - ptr_var: INTPTR = c.Addr(s) + # c.Addr(s) 取的是局部变量 s(str = i8*)的地址,结果是 i8**(char**); + # 与 INTPTR(= t.CInt | t.CPtr,int*,见 includes/stdint.vp)层数与基座都不同, + # 且指针隐式转换已收紧(层数必须相同)⇒ 注解按实际类型写 str | t.CPtr(= i8**)。 + ptr_var: str | t.CPtr = c.Addr(s) val_var: int = 42 if c.CIf(ctraits.isptr(ptr_var)): print("ptr_var is pointer")