Skip to content
Systems programming for what’s next.
— Vex

Linting and Verified Fixes ​

vex lint is Vex's canonical source-analysis command. It runs parser, resolution, type, control-flow, borrow, ABI, and validation checks together with the configurable lint registry, without invoking LLVM code generation.

Use it for ordinary diagnostics, CI quality gates, safe cleanup, and source migrations:

bash
vex lint src/main.vx
vex lint .
vex lint --fix .
vex lint --diff --only pointer_migration .
vex lint --format json --deny-warnings .
vex lint --format sarif .
vex lint --format json --timings .
vex lint --analyze-comptime .
vex lint --explain-boxing src/main.vx
vex lint --explain-arena src/main.vx

The former vex check, vex analyze, and vex fix compatibility commands have been removed. Use vex lint, vex lint --fix, or vex lint --diff.

--explain-boxing exposes VUMM ownership/boxing decisions and --explain-arena exposes AutoArena allocation decisions. They are diagnostic views over the same semantic session, not separate analysis commands.

--analyze-comptime runs the shared typed staging probe after successful semantic analysis and writes an aggregate known/residual/error summary to stderr. Lint findings in text, JSON, and SARIF remain unchanged. The option is default-off and never applies staged replacements.

Analysis targets ​

TARGET may be:

  • one .vx or .vxc file;
  • a package directory;
  • omitted, in which case Vex discovers the nearest enclosing vex.json.

A directory must belong to a package. Vex rejects an unscoped repository root instead of merging all nested packages into one enormous analysis session, and package inventory stops at nested vex.json boundaries.

Directory analysis selects the source variants matching the active target OS and architecture. Cross-target analysis uses the same routing as compilation:

bash
vex lint --target x86_64-pc-windows-msvc .

.git, .vex, .vxm, target, build, vendor, and generated directories are skipped by default. Package-specific exclusions can be added in vex.json. Compiler-generated vex_test_runner_*, .vex_test_runner_*, and .vex_bench_* files are execution artefacts rather than package members, so lint excludes them even if an interrupted test or benchmark process left them beside the original source.

Diagnostics versus lints ​

vex lint reports two kinds of findings:

  1. Correctness diagnostics are compiler errors such as invalid syntax, unresolved names, type mismatches, borrow violations, illegal pointer capability escalation, and invalid FFI declarations. They cannot be disabled.
  2. Lint diagnostics are configurable findings with stable symbolic IDs. Their levels are allow, warn, or deny.

This separation matters in fix mode: an unrelated existing compiler error may coexist with an exact syntax migration, but a semantic cleanup never runs without the phase that proves it safe.

Current rules ​

RuleGroupWhat it detectsAutomatic fix
unused_importunusedresolved imports with no semantic useyes
unused_localunusedlocal bindings with no semantic readssuggestion; deletion only when proven effect-free
unused_mutabilityunusedbinding mutability never requiredyes
unused_assignmentunusedvalue overwritten before any readyes when the RHS is effect-free
ignored_resultunuseddiscarded value resolving to the canonical Result lang itemno
unawaited_futureunuseddiscarded value whose resolved type is Futureno
redundant_identity_castredundancyexact non-pointer identity castsyes
redundant_literal_castredundancya literal suffix already fixes the destination typeyes
redundant_pointer_castpointer_migrationexact pointer identity castsyes, only with semantic identity proof
redundant_cloneredundancycloning an exact Copy valueyes
no_effect_statementredundancydiscarded expression proven effect-freeyes
self_assignmentsuspiciousboth sides resolve to the same semantic placeyes
unreachable_codesuspiciouslocal code after unconditional control flowsuggestion
suspicious_shadowingpedantica nested same-named binding ends and the exact outer binding resumesno; opt-in
unreachable_match_alternativepedanticearlier unguarded alternatives fully cover an exact bool/enum patternno; opt-in
borrowed_value_escapespedantica borrowed/view value crosses an exact container-store or channel boundaryno; opt-in
constant_comparisonsuspiciouscomparison result proven by typed operand rangesno
empty_rangesuspiciousrange proven empty by typed boundsno
empty_blocksuspiciousempty block without an explanatory commentsuggestion
deprecated_syntaxmigrationsupported legacy grammar with an exact replacementyes
legacy_pointer_syntaxpointer_migrationptr, *T, legacy null castsyes
legacy_void_typepointer_migrationlegacy Vex void type positionsyes
discarded_allocationperformanceexactly proven allocation result immediately discardedno; opt-in
last_use_owned_cloneperformancea non-Copy owned local is cloned at its proven final non-repeating useno; opt-in
exported_allocationapiexported function with allocation in its transitive effect summaryno; opt-in
exported_raw_pointer_abiapiexported Vex signature exposing a raw pointer capabilityno; opt-in
exported_borrowed_returnapiexported return is a borrow/view derived from an exact input bindingno; opt-in
exported_ownership_transferapiexported return transfers ownership out of an exact input/receiver chainno; opt-in
redundant_contract_boundpedantica resolved bound is implied by another exact contract inheritance edgeno; opt-in
out_of_range_numeric_castpedanticinteger value range proven outside the target typeno; opt-in
potentially_lossy_numeric_castpedanticnumeric type domains cannot preserve every source valueno; opt-in

The default profile warns for correctness-adjacent, unused, redundancy, suspicious, and migration rules. Evidence-backed performance, API, and pedantic rules remain allow until selected. Unknown selectors are configuration errors instead of silently doing nothing.

Available profiles are:

ProfileAdditional opt-in groups
defaultnone
performanceperformance
pedanticpedantic
libraryapi
strictperformance, pedantic, api

An explicit rule/group level overrides profile promotion. --only also promotes the selected opt-in rule or group to warn, unless it was explicitly set to allow.

Pointer migration ​

The canonical raw-pointer surface is:

vex
Ptr<T>         // readable pointee capability
Ptr<T!>        // writable pointee capability
Ptr<Opaque>    // opaque C-compatible object pointer

The focused migration group performs syntax-aware conversions:

text
ptr                 -> Ptr<Opaque>
*T                  -> Ptr<T>
*T!                 -> Ptr<T!>
0 as *T             -> Ptr.null<T>()
fn callback(): void -> fn callback(): ()
Result<void, E>     -> Result<unit, E>

Run it independently from unrelated cleanup rules:

bash
vex lint --only pointer_migration legacy-package
vex lint --diff --only pointer_migration legacy-package
vex lint --fix --only pointer_migration legacy-package

Direct function and callback results use (). Nested or value-position unit types use the unit keyword because it is unambiguous inside generic grammar. C source embedded as a compiler fixture remains C and is not interpreted as Vex pointer syntax.

Why --fix is conservative ​

vex lint --fix does not apply a bag of textual replacements. Every edit is:

  • attached to the exact source revision and expected original text;
  • planned with overlap and conflict detection;
  • applied first to an in-memory workspace;
  • reparsed and semantically reanalyzed;
  • iterated to a fixed point, with a maximum of four passes;
  • written atomically only after verification succeeds.

Verification fingerprints function identity, inferred signatures and bindings, callable and overload selection, generic arguments, call operand/result types, and correctness diagnostics. If a fix changes a semantic decision or introduces a new compiler error, no files are committed.

Use --diff to run the same verified pipeline without writing:

bash
vex lint --diff .

Rule selection and levels ​

bash
vex lint --only unused .
vex lint --allow empty_block .
vex lint --warn performance .
vex lint --deny unused_import .
vex lint --deny-warnings .

--only selects one rule or group while correctness analysis still runs. Repeated --allow, --warn, and --deny flags may target either a symbolic rule ID or a group. CLI settings override manifest settings.

Package configuration lives in vex.json:

json
{
  "lint": {
    "profile": "default",
    "levels": {
      "unused": "warn",
      "unused_import": "deny",
      "pedantic": "allow"
    },
    "exclude": ["generated/**", "vendor/**"],
    "baseline": ".vex/lint-baseline.json"
  }
}

Staged CI baselines ​

A baseline lets an existing package adopt strict lint gates without hiding its current debt:

bash
vex lint --deny-warnings --write-baseline .vex/lint-baseline.json .
vex lint --deny-warnings --baseline .vex/lint-baseline.json .

Baseline findings remain present in terminal, JSON, SARIF, and editor output; they are tagged as baselined and do not fail the lint gate. New findings do. Compiler correctness errors are never baselined. Reports include matched, new, and stale counts, making obsolete entries visible instead of silently accumulating them.

The file is strict, versioned JSON and is written atomically. Entries use package-relative paths and source-aware anchors rather than absolute line numbers, so inserting unrelated lines does not churn the baseline. Configure it once in vex.json with lint.baseline; an explicit --baseline path overrides the manifest.

Local suppression ​

Suppressions use stable rule or group IDs:

vex
// vex-lint: allow-file unused_import, deprecated_syntax

fn example() {
    // vex-lint: allow-next unused_mutability
    let! intentionallyMutable = 1
}

allow-file is valid only before the first item. allow-next applies to the next syntax item or statement. Suppressed diagnostics remain visible in JSON metadata so editors and audit tools can explain the decision.

Correctness errors cannot be suppressed this way.

Machine-readable output and editors ​

bash
vex lint --format json .
vex lint --format sarif .
vex lint --format json --timings .

JSON reports stable rule IDs, groups, levels, byte ranges, notes, structured fixes, applicability, source revisions, and suppression metadata. Diagnostic ordering is deterministic by file, source offset, severity, and rule ID. The top-level semantic_fact_schema_version lets consumers version semantic facts independently from diagnostic wording. Schema v5 models pattern-binding origins and treats clone, transfer, and exact owning coercions such as str -> string as ownership provenance barriers. It consumes the compiler-owned Copy contract identity and distinguishes immutable program-storage literals from ordinary borrows. Trusted container and channel facts also identify the exact parameter slots that escape; indices and other non-stored arguments are never inferred to escape.

SARIF 2.1.0 carries compiler correctness and lint results for external code scanners without changing the canonical JSON schema. --timings adds sorted per-rule invocation, finding, and elapsed-nanosecond telemetry to JSON/SARIF. Ordinary lint runs avoid clock reads entirely.

Machine formats always emit exactly one parseable document. --diff and --explain-boxing/--explain-arena therefore require text output; fix status messages are suppressed for JSON/SARIF.

The Vex language server consumes the same LintReport and source revisions as the CLI. Quick fixes and source.fixAll.vex use the shared conflict planner; the editor does not rediscover warnings or reconstruct edits from message text.

Exit status ​

CodeMeaning
0no correctness errors or denied lints; ordinary warnings are allowed
1correctness errors, denied lints, or warnings denied by --deny-warnings
2invalid target, option, output format, or lint configuration
3fix planning or verification failed; no partial write was committed
101internal compiler or linter failure

Stability boundary ​

The source tree contains tests for the registry, configuration, suppressions, reporting, LSP integration, revision-bound fixes, transactional writes, four-pass cycle guard, target-aware source routing, and pointer migration. These test definitions explain intended behavior; release qualification needs their results for the selected compiler and target. Do not infer Linux or Windows execution from a macOS run, or native program correctness from a successful lint check.

The V2 corpus calibration covers VexArch and every standard-library package. Opt-in ownership/API findings remain visible for explicit review rather than being hidden to claim a clean corpus. Corpus review moved provably out-of-range casts to pedantic, because explicit signed-to-unsigned sentinel encodings are a valid low-level pattern; genuine discarded Result findings are fixed instead of suppressed.

Automatic fixes intentionally cover less than diagnostics. Vex does not automatically rewrite pointer provenance, pointer/integer conversions, address-space changes, numeric narrowing, general arithmetic, alias-sensitive global stores, or speculative performance transformations.

V2 semantic foundation ​

V2 extends the same engine rather than introducing another linter. A lazy, revision-bound schema-v5 fact graph now owns exact call edges, transitive effect and allocation summaries, value provenance, compact ownership-transition and parameter-origin chains, exact unreachable match alternatives, and target-aware integer/conversion ranges. Reverse call edges use a monotone worklist, so only callers affected by a growing callee summary are revisited; recursive cycles converge without per-rule HIR recursion. All selected body rules share the same lowered body, inference result, binding facts, and V2 facts. Must-use ownership also prevents generic no_effect_statement from duplicating Result/Future diagnostics or offering an unsafe deletion fix.

Ordinary lint analysis uses a semantic diagnostics snapshot and never flattens the import graph into a codegen module. The more expensive VUMM/codegen-ready snapshot is requested only by --explain-boxing or --explain-arena. Likewise, the full overload/signature/binding fingerprint is built only for --fix and --diff, where it proves that a proposed edit preserved semantics. This keeps normal diagnostics free of codegen-only module merging without weakening fix verification.

For one-document editor runs, only the active file's reachable loaded imports join the fact graph as non-reporting support modules. Their effects reach the active file, while their diagnostics remain owned by their own publication and unrelated open files do not inflate the analysis.

The first correctness, performance, and API rules listed above are implemented. Long-lived LSP sessions now retain a bounded semantic-fact cache across source revisions. Reuse requires exact Salsa body, signature, inference, and lang-item identity plus matching target and callee summaries; a dependency change cannot reuse stale caller effects. Rule work is also bounded-parallel: small jobs stay serial, larger jobs use at most four owned Salsa database forks and always merge in semantic source order. Exact borrowed escape, public ownership, last-use clone, resumed shadowing, unreachable-alternative, and redundant-bound rules consume these facts. Dead-private-item analysis remains gated on explicit entry/test/reflection root identities; it will not guess roots from names. Machine-readable staged-CI baselines are implemented.

No V2 rule may infer meaning from a function or type name. Default-profile admission requires corpus false-positive review, and automatic fixes retain V1's atomicity, idempotence and semantic-fingerprint verification. Performance rules cannot assume that LLVM will make a transformation safe or profitable.

Released under the MIT License.