Harden M2 compiler and language contract (#294–#299)#300
Merged
Conversation
Implements the M2 compiler/language-contract additions tracked by #294-#299. - #299: ADR 0010 commits to a shared tokenizer plus recursive-descent parser with error recovery, migrated behind the stable gwdkast AST seam. Wires the decision into the decisions index and the pipeline doc. - #294: source.SourcePosition carries a 0-based byte Offset, with PositionAt and OffsetOf rune-accurate conversion helpers as the exact-span substrate. - #296: the formatter tracks brace depth with the parser's string- and comment-aware scanner, so braces inside string literals, comments, and template literals no longer skew indentation. - #297: conflict diagnostics (duplicate_route and route_method_conflict, including contract-route conflicts) carry a related "first declared here" location. check --json gains an additive `related` array and the LSP emits relatedInformation. - #295: a machine-checked .gwdk conformance corpus (accept/reject cases with golden diagnostic codes) pins the language contract, referenced from the spec, grammar, and syntax-contributor docs. - #298: a per-construct stability and deprecation table, with metadata keywords DRYed into lang.MetadataKeywords and view.SupportedDirectiveNames exported, guarded against drift by a cross-check test. Tests: go test ./internal/... ./cmd/... . all pass; gofmt and go vet clean; node --test editors/vscode/*.test.js passes (39).
This was referenced Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the remaining M2 — Compiler + Language Contract issues. Each is a non-breaking slice landed behind the stable
gwdkastAST seam, with tests.What's in here
#299 — Parser direction (ADR)
ADR 0010 commits to a shared tokenizer + recursive-descent parser with error recovery, migrated behind the stable
gwdkastAST seam. The decision is grounded in two facts: the target pipeline already names alex/parse full ASTfront-end, andinternal/lang.Lexis already a real tokenizer (only tooling uses it). Wired into the decisions index anddocs/compiler/pipeline.md.#294 — Byte offsets in source positions
source.SourcePositiongains a 0-based byteOffset, plussource.PositionAt/source.OffsetOfrune-accurate conversion helpers (round-trip tested). This is the exact-span substrate for AST-backed formatting and precise LSP edits. Parser-internal population is sequenced behind #299 (the field is best-effort; unset offsets stay zero, as the issue allows). The JSON-facinglang.Positionis intentionally untouched socheck --jsongoldens are stable.#296 — Formatter brace safety
The formatter now tracks brace depth with the parser's string/comment-aware scanner (
parser.NewBraceDepth) instead of naivestrings.Count. Braces inside string literals, comments, and template literals (e.g.title "a { b",// note about }) no longer skew indentation. Idempotence preserved.#297 — Related spans in conflict diagnostics
duplicate_routeandroute_method_conflict(including contract-route conflicts, which flow through the same registration path) now carry a related "first declared here" location.check --jsongains an additiverelatedarray; the LSP emitsrelatedInformation. Newsource.RelatedSpan+ValidationError.Relatedthread it through compiler → lang → LSP.#295 — Machine-checked conformance corpus
internal/lang/testdata/conformance/{accept,reject}pins the language contract: accept cases must check clean, reject cases must produce the stable diagnostic code named in a leading// expect:directive. Runner inconformance_test.go; referenced as the contract source of truth from the spec, grammar, and syntax-contributor checklist. Seedocs/language/conformance.md.#298 — Per-construct stability table
docs/language/stability.mdpublishes stable/partial/planned/deprecated tiers for blocks, metadata keywords, andg:directives. Metadata keywords are DRYed intolang.MetadataKeywords(removing duplication between the lexer and formatter) andview.SupportedDirectiveNamesis exported; a guard test cross-checks the doc against both registries.Verification
go test ./internal/... ./cmd/... .— all passgofmt -landgo vet ./internal/... ./cmd/...— cleannode --test editors/vscode/*.test.js— 39 pass, 0 failgit diff --check— cleanNotes
🤖 Generated with Claude Code