From 4bc462e0f34a434ac788b19712f95d043c341dbb Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Tue, 22 Sep 2026 20:39:52 +0800 Subject: [PATCH] =?UTF-8?q?feat(vipeye-internal):=20long/longlong=20?= =?UTF-8?q?=E4=B9=9F=E4=BD=9C=E4=B8=BA=E5=86=85=E7=BD=AE=20C=20=E5=9F=BA?= =?UTF-8?q?=E6=9C=AC=E7=B1=BB=E5=9E=8B=20typedef?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 对齐编译器 t.py 的 _CNAME_ALIAS(char/short/long/unsigned 等是语言内置名称, 无需 import):在 builtins.vpi 内置 long → t.CLong、longlong → t.CLongLong。 C 的 "long long" 含空格不能作标识符,故 Viper 写作 longlong;无符号形式仍可用 t.CUnsignedLongLong。 回归用例补充 g(e: long, h: longlong) -> long 的注解类型断言(CLong/CLongLong)。 版本号提升至 1.1.418 并更新 CHANGELOG。 --- packages/vipeye-internal/package-lock.json | 4 ++-- packages/vipeye-internal/package.json | 2 +- .../src/tests/viperBuiltinsVpTypedef.test.ts | 12 ++++++++++++ .../typeshed-fallback/stdlib/builtins.vpi | 7 +++++++ packages/vipeye/package-lock.json | 4 ++-- packages/vipeye/package.json | 2 +- packages/vscode-vipeye/CHANGELOG.md | 4 ++++ packages/vscode-vipeye/package-lock.json | 4 ++-- packages/vscode-vipeye/package.json | 2 +- 9 files changed, 32 insertions(+), 9 deletions(-) diff --git a/packages/vipeye-internal/package-lock.json b/packages/vipeye-internal/package-lock.json index df5fe835..b8b6d75a 100644 --- a/packages/vipeye-internal/package-lock.json +++ b/packages/vipeye-internal/package-lock.json @@ -1,12 +1,12 @@ { "name": "vipeye-internal", - "version": "1.1.417", + "version": "1.1.418", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vipeye-internal", - "version": "1.1.417", + "version": "1.1.418", "license": "MIT", "dependencies": { "@yarnpkg/fslib": "2.10.4", diff --git a/packages/vipeye-internal/package.json b/packages/vipeye-internal/package.json index 477cac07..2a7e8b5e 100644 --- a/packages/vipeye-internal/package.json +++ b/packages/vipeye-internal/package.json @@ -2,7 +2,7 @@ "name": "vipeye-internal", "displayName": "vipeye", "description": "Type checker for the Viper language", - "version": "1.1.417", + "version": "1.1.418", "license": "MIT", "private": true, "files": [ diff --git a/packages/vipeye-internal/src/tests/viperBuiltinsVpTypedef.test.ts b/packages/vipeye-internal/src/tests/viperBuiltinsVpTypedef.test.ts index fb95c747..b830921f 100644 --- a/packages/vipeye-internal/src/tests/viperBuiltinsVpTypedef.test.ts +++ b/packages/vipeye-internal/src/tests/viperBuiltinsVpTypedef.test.ts @@ -314,6 +314,9 @@ test('无 includes/builtins.vp 时,内建 builtins.vpi 提供 uint32/sizet/int def f(a: uint32, b: sizet, c: int8, d: uint64) -> uint32: return a + +def g(e: long, h: longlong) -> long: + return e `, 'utf8' ); @@ -365,6 +368,15 @@ def f(a: uint32, b: sizet, c: int8, d: uint64) -> uint32: ); } + // C 基本类型名:long → CLong,longlong → CLongLong + const gTypes = types.get('g') ?? []; + for (const expected of ['CLong', 'CLongLong']) { + assert( + gTypes.some((t) => t.includes(expected)), + `g() 参数注解应包含 ${expected},实际: ${JSON.stringify(gTypes)}` + ); + } + program.dispose(); serviceProvider.dispose(); fs.rmSync(testRoot, { recursive: true, force: true }); diff --git a/packages/vipeye-internal/typeshed-fallback/stdlib/builtins.vpi b/packages/vipeye-internal/typeshed-fallback/stdlib/builtins.vpi index ce38f41d..82e8ee53 100644 --- a/packages/vipeye-internal/typeshed-fallback/stdlib/builtins.vpi +++ b/packages/vipeye-internal/typeshed-fallback/stdlib/builtins.vpi @@ -2751,6 +2751,13 @@ rawptr: t.CTypedef = t.CPtr # "未定义"(同一工程在不同编辑器里表现不一致)。 # 因此在 builtins stub 中内建一份等价声明:任意 Viper 工程无需配置 includes 即可 # 解析;工程自带 builtins.vp 时仍以工程声明为准(合并逻辑会覆盖同名符号)。 +# +# C 基本类型名(对齐编译器 t.py 的 _CNAME_ALIAS:char/short/long/unsigned 等是 +# 语言内置名称,无需 import)。C 的 "long long" 含空格、不能作标识符,Viper 写作 +# longlong;"unsigned long long" 同理不内建,需要时写 t.CUnsignedLongLong。 +long: t.CTypedef = t.CLong +longlong: t.CTypedef = t.CLongLong + sizet: t.CTypedef = t.CSizeT size_t: t.CTypedef = sizet uzt: t.CTypedef = sizet diff --git a/packages/vipeye/package-lock.json b/packages/vipeye/package-lock.json index 971989fc..8570449d 100644 --- a/packages/vipeye/package-lock.json +++ b/packages/vipeye/package-lock.json @@ -1,12 +1,12 @@ { "name": "vipeye", - "version": "1.1.417", + "version": "1.1.418", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vipeye", - "version": "1.1.417", + "version": "1.1.418", "license": "MIT", "bin": { "vipeye": "index.js", diff --git a/packages/vipeye/package.json b/packages/vipeye/package.json index 4b824aec..6c8946d5 100644 --- a/packages/vipeye/package.json +++ b/packages/vipeye/package.json @@ -2,7 +2,7 @@ "name": "vipeye", "displayName": "Vipeye", "description": "Type checker for the Viper language", - "version": "1.1.417", + "version": "1.1.418", "license": "MIT", "author": { "name": "TermiNexus" diff --git a/packages/vscode-vipeye/CHANGELOG.md b/packages/vscode-vipeye/CHANGELOG.md index e3750807..487a6054 100644 --- a/packages/vscode-vipeye/CHANGELOG.md +++ b/packages/vscode-vipeye/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 1.1.418 + +- **Built-in C basic type names**: `long` (`t.CLong`) and `longlong` (`t.CLongLong`) are now built-in typedefs, mirroring the compiler's `_CNAME_ALIAS` table (`char`, `short`, `long`, `unsigned` and friends are language built-ins that need no import). C's `long long` cannot be spelled with a space, so Viper writes `longlong`; the unsigned form stays available as `t.CUnsignedLongLong` + ## 1.1.417 - **Built-in C integer typedefs**: `sizet`, `size_t`, `uzt`, `int8`–`uint64`, `intfast*`/`uintfast*`, `intleast*`/`uintleast*` are now declared in the built-in `builtins.vpi` stub, mirroring the compiler's `includes/builtins.vp`. Any Viper project resolves them without configuring `includes`, which fixes `uint32` (and the rest) being reported as undefined in setups where the project-level `builtins.vp` cannot be located — that lookup depends on the workspace root and the set of opened files, so the same project could behave differently across editors diff --git a/packages/vscode-vipeye/package-lock.json b/packages/vscode-vipeye/package-lock.json index 514f33bf..d926438a 100644 --- a/packages/vscode-vipeye/package-lock.json +++ b/packages/vscode-vipeye/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-vipeye", - "version": "1.1.417", + "version": "1.1.418", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vscode-vipeye", - "version": "1.1.417", + "version": "1.1.418", "license": "MIT", "dependencies": { "mermaid": "^11.12.0", diff --git a/packages/vscode-vipeye/package.json b/packages/vscode-vipeye/package.json index 516c38a3..36eed43e 100644 --- a/packages/vscode-vipeye/package.json +++ b/packages/vscode-vipeye/package.json @@ -2,7 +2,7 @@ "name": "vscode-vipeye", "displayName": "Vipeye", "description": "VS Code language support for Viper (LSP client)", - "version": "1.1.417", + "version": "1.1.418", "private": true, "license": "MIT", "author": {