Tya v0.38 Specification — Canonical Syntax (Landing)

Tya v0.38 lands the Canonical Syntax described in docs/CANONICAL_SYNTAX.md: every Tya program now has a single canonical source representation, and tya fmt (alias tya format) is the canonical serializer. The v0.33–v0.37 minor releases progressively introduced parenthesized multi-parameter lambdas, the comment-capture lexer pipeline, the per-statement comment AST, the Unparse foundation, and the §5 wrap rules. v0.38 connects them into a default-on canonical formatter.

Goals (v0.38)

Non-Goals (v0.38)

CLI Surface

tya fmt [-w] [--text] [path]
tya format [-w] [--text] [path]
Flag Behavior
(none) AST-driven canonical serializer (default in v0.38).
-w Write canonical output back to the file.
--text Use the v0.2 text pass (transitional opt-out). Removed in a future release.
--ast Explicitly request the AST serializer (already the default).

When the AST serializer encounters an unsupported AST shape, the CLI gracefully falls back to the text pass for that file. This keeps editor save hooks safe even on programs that exercise features not yet covered by Unparse.

Self-Host Realignment

selfhost/v01/compiler.tya is itself a Tya program; previously it parsed only the v0.1 surface and could not consume the canonical wrap forms. v0.38 extends the Tya-written compiler so it can:

With these in place, tya fmt selfhost/v01/compiler.tya produces canonical output that the same compiler can then compile, so the self-host fixed point continues to hold against the canonical formatter.

Tests

Acceptance Criteria

A v0.38 build is acceptable when:

  1. tya fmt path.tya and tya format path.tya produce the canonical AST-driven layout by default.
  2. Running tya fmt -w over examples/, stdlib/, and selfhost/v01/ is idempotent.
  3. TestSelfhostV01Scripts passes.
  4. go test ./... -count=1 passes.
  5. Each CANONICAL §5 wrap rule and §6.3 triple-quote rewrite is exercised by at least one unit test in internal/formatter/unparse_test.go.
  6. The corpus round-trip test in internal/formatter/corpus_test.go reports zero unsupported files for the maintained codebase (archived pre-v0.1 sources may remain unsupported).

Deferred to v0.38.x / v0.39

References