kern check

The KERN nominal type checker — deterministic, zero false positives by design. It only fires on violations it can prove; anything ambiguous is skipped, never guessed.

Usage

kern check                  # Check every .kern file under cwd
kern check src/             # Check a directory
kern check api.kern         # Check one file
kern check --json           # Machine output (schemaVersion 1.0) for CI/bots
kern check --quiet          # Print only the summary line
kern check --strict         # Warnings also cause a non-zero exit
kern check --with-semantics # Also run semantic validation

What it checks

  • Class declarations and override variance — single inheritance, abstract members, and Liskov-checked overrides.
  • Call-site arity and argument types — too few or too many arguments, and provable type mismatches.
  • Declared returns — annotate a function with returns=<Class> and the checker verifies every literal return value="new <Class>(...)" against it.
class name=Dog
class name=Cat
fn name=mk returns=Dog
  handler lang=kern
    return value="new Cat()"   # kern check: check-return-type error

Exit codes

Designed to drop straight into CI before kern review:

  • 0 — clean (no error-severity diagnostics; no warnings under --strict).
  • 1 — findings (at least one error, or a warning under --strict).
  • 2 — operational failure (distinct from diagnostic-driven exit 1).

JSON contract

--json emits a stable, machine-readable payload with schemaVersion "1.0" for CI gates and bots. Each diagnostic carries a rule id, severity, message, and an optional 1-based line and column.

Pairs with kern review

kern check verifies type correctness; kern review handles security, taint, unguarded effects, and framework contracts. Run check first, then review.