TermiNexus baec16e540 feat(vipeye-internal): Viper 1.1.426 语法/语义/补全增强
把 TransPyC 现行语法与 Viper 的类型组合语义补齐到 LSP 侧(编译器 TPC/TPV 不改动):

- 类型描述符:`const` / `volatile` 可前缀任意类型注解并成为硬关键字(仅注解前缀
  合法,`const = 1` / `a: const` 报语法错误),解析层脱糖为等价的 `CConst | T` /
  `CVolatile | T`,与手写 TypeSet 完全同形;`const T*` 得 `CConst | CPtr[T]`;
  `T*` / `&x` 不再要求 import t(回退 builtins 的 rawptr);描述符按「前缀限定符」
  渲染(`const int` / `const volatile int` / `const rawptr[int]`)而不泄漏为联合成员
- 新增 `inline while` / `inline for`;`const` / `volatile` / `inline` 高亮为修饰符
- 新增内建类型名 uint / uchar,并把 rawptr / sizet / int8..uint64 / uintfast* /
  uintleast* 等内建到 builtins.vpi,任意 Viper 工程无需配置 includes
- 新增 `virtual` / `novirtual` 声明修饰符(等价 @t.CVTable / @t.NoVTable),
  含放置位置校验,并并入补全与高亮
- `(T**)x` 两级指针强转修复:指针类型后缀统一按类型表达式求值,不再被当成解引用
- 裸内置内联汇编 / LLVM IR:`__asm__` / `asminp` / `asmout` / `__llvmir__` /
  `irinp` / `irout` / `ASM_DESCR`,与 c.* / t.ASM_DESCR 写法等价
- `X | t.CPtr` 在 X 本身是指针时再包一层(HANDLE | t.CPtr = void**),
  修复 CreatePipe 一类 LPHANDLE 的「跨级指针隐式转换不允许」误报
- 补全并入 Viper 专有关键字(define / const / volatile / typedef / inline / export /
  extern / virtual / novirtual / enum / rnum / union / struct / fn / fun / func / function)
- `T*(x)`:裸模块名 + 模块内同名类归一为 CPtr[bootinfo];并按 TPC `_AtPtrSuffixCall`
  的判据把「类型原子 + 紧贴星串 + 紧贴 (」解析为调用,使
  `uint32*(info.vendor_id)[0] = res.ebx` 成为合法赋值目标
- 新增「重复声明」检查:模块级已有同名运行期变量时,函数内再用类型注解声明同名
  变量无条件报 TypeError(与 TPV AssignGenMixin 同口径);排除 CDefine 宏、CTypedef
  别名、同名函数/类与类体成员。合法写法只剩 `global x` + 无注解赋值,或换名
- 支持 `__attribute__`:装饰器 `@__attribute__(...)` 脱糖为
  `@c.Attribute(t.attr.X, ...)`;注解修饰器 `a: __attribute__(...) const int`
  脱糖为 `t.attr.X | (CConst | int)`;注解联合中的 `t.attr.*` 标记求值为 t.CAttr
  修饰符(运算/下标/赋值/展示均按被修饰的基础类型处理);值位置
  `volatile f()` / `volatile 结构体()` 前缀;`__a` 补全、括号内属性名补全与悬停、
  TextMate 高亮
- 注解位置小写 `callable[[A, B], R]` 等价 t.Callable:parser 仅在类型注解位置把裸名
  `callable` 脱糖为 `Callable`,builtins.vpi 内建 `Callable` 别名(无需 import t);
  值位置 `callable(x)` 仍是内置函数
- 版本号提升至 1.1.426 并更新 CHANGELOG;新增 6 个回归测试文件、更新 4 个,
  全量 64 套件 / 794 用例全绿(另有 1 套件 8 用例为既有 skip)
2026-09-27 12:50:02 +08:00
2026-07-24 17:08:39 +08:00
2026-07-24 17:08:39 +08:00
2026-07-24 17:08:39 +08:00
2026-07-24 17:08:39 +08:00
2026-07-24 17:08:39 +08:00
2026-07-24 17:08:39 +08:00
2026-07-24 17:08:39 +08:00
2026-07-24 17:08:39 +08:00
2026-09-18 21:49:07 +08:00
2026-07-24 17:08:39 +08:00

Vipeye

Vipeye — Static Type Checker and Language Server for Viper

Vipeye is a full-featured, standards-based static type checker and language server for Viper, written in TypeScript. It is designed for high performance and can be used with large Viper source bases.

Vipeye ships in three forms:

  • a language server (vipeye-langserver) speaking LSP over stdin/stdout;
  • a command-line type checker (vipeye);
  • an extension for Visual Studio Code (vscode-vipeye), which bundles both the LSP client and the Viper core UI (project / toolchain).

It is built on the Pyright codebase, adapted from the ground up to Viper semantics (AOT compilation, C-style type system, pointer and memory semantics). Python analysis is no longer supported — only the Viper dialect is checked.

What is Viper

Viper is an ahead-of-time (AOT) compiled language whose syntax is modeled on CPython but whose semantics are entirely different:

  • TPC — the seed compiler, itself based on CPython, used to bootstrap the toolchain.
  • TPV — the first self-hosted compiler, written in Viper. Once tpv --lsp lands, it will replace the Pyright-derived analyzer in this repository.

Vipeye exists to provide type checking, diagnostics and editor intelligence for .vp / .vpi sources while TPV's own language server is under development.

Capabilities

Viper language semantics

  • C-style type system: t.CPtr, t.CArray, t.CVoid, t.CTypedef, t.CDefine, t.CEnum, t.REnum, plus the compiler built-ins char, double and rawptr (a raw-pointer typedef).
  • Pointer and memory semantics: CPtr[T] / rawptr[T], c.Deref, address-of, pointer arithmetic and indexing; a __new__ returning a raw pointer is auto-wrapped into CPtr[T].
  • C declaration modifiers (t.CInline, t.CStatic, t.CConst …) are filtered out during type merging — only the underlying data type is kept.
  • Declaration modifiers on functions, with fn / fun / func / function as aliases of def.
  • struct / union / enum / rnum, including nested t.REnum variants destructured by field order.
  • Variadic *args bound as va_list in the function body (va_arg, and pointer passthrough such as vsnprintf(buf, size, fmt, args)).
  • Implicit conversion rules: integer/float convert in all directions (safe narrowing, lossless widening); integer → float requires float width ≥ integer width; float → integer is rejected; pointers of the same level may convert, different levels may not; explicit casts are always allowed.
  • Global/local variable rules: reading a global never errors; assigning an undeclared global without global does; a local redeclaration shadows the global; and so on.
  • Type representations: bool / t.CBool map to i1; str / bytes are i8*, while str | t.CPtr / bytes | t.CPtr are i8**.
  • PEP 695 syntax is pre-processed for Viper: type parameter lists are stripped and unknown T | t.CPtr unions are folded to i8*.
  • Fail-fast analysis: missing type information is reported as an error instead of silently degrading to i8* / void / i32.

Editor features

  • Diagnostics with human-readable messages, plus Viper-tuned semantic highlighting (keywords, decorators, t.CDefine constants, and undefined symbols rendered in white).
  • Completion, hover, go-to-definition, find references, rename, document symbols, and Organize Imports.
  • Activity-bar UI (Project / Toolchain / Settings), .vpj project files with a dedicated custom editor, and a status-bar compiler indicator.
  • Import resolution over VIPER_HOME (stdlib), viperconfig.json extra paths, the workspace root, and recursively discovered child project configurations.

Packages

  • packages/vipeye-internal — Core analysis engine: parser, binder, type evaluator, checker, and language service. All logic lives here.
  • packages/vipeye — CLI wrapper. Bundles vipeye-internal into a distributable npm package with vipeye and vipeye-langserver entry points.
  • packages/vipeye-typeserver — Type server process for long-running editor sessions.
  • packages/vscode-vipeye — VS Code extension client (Vipeye LSP), with the Viper core source (packages/viper) bundled at build time.
  • packages/viper — Viper core source library: project (.vpj) management, toolchain, and the activity bar UI (Project / Toolchain / Settings).

Relationship to Pyright

  • Viper dialect: viperconfig.json instead of pyrightconfig.json; configuration namespace viper.* instead of python.analysis.* / pyright.*.
  • Viper stdlib stubs bundled in packages/vipeye-internal/vipershed-fallback.
  • Type semantics follow Viper rules: implicit conversions, pointer types (CPtr / CArray), t.CTypedef / t.CDefine / t.CEnum / t.REnum, T | t.CPtr pointer folding, global-variable access rules, and more.
  • Diagnostics and semantic highlighting are tailored to Viper syntax.

Building and Testing

# Install all packages (from repo root)
npm install

# Build the core library
cd packages/vipeye-internal && npm run build

# Run all tests (rebuilds the test server first)
cd packages/vipeye-internal && npm test

# Run tests without rebuilding the test server (faster iteration)
cd packages/vipeye-internal && npm run test:norebuild

# Build the CLI / VS Code extension bundles (from repo root)
npm run build:cli:dev
npm run build:extension:dev

See docs/build-debug.md for details.

Documentation

Refer to the documentation for installation, configuration, and usage details.

Environment variables

If Vipeye fails to create a temporary directory (for example in remote/server environments where the OS temp directory doesn't exist or isn't writable), you can override the temp directory root:

  • VIPEYE_TMPDIR: Absolute path to a directory that Vipeye can use for temporary files/directories. Vipeye will create it if needed.

Vipeye otherwise relies on the platform temp directory (for example TMPDIR, TMP, TEMP, or the OS default).

License

MIT

S
Description
A thin wrapper layer for Viper LSP that reuses Pyright
Readme
29 MiB
0 Stars 1 Watchers 0 Forks
2026-08-27 10:28:15 +08:00
Languages
JSON-with-Comments 49.2%
TypeScript 48.9%
Python 1.5%
JavaScript 0.4%