Skip to content

Stage c/218 records and codemod#310

Closed
hyperpolymath wants to merge 2 commits into
mainfrom
stage-c/218-records-and-codemod
Closed

Stage c/218 records and codemod#310
hyperpolymath wants to merge 2 commits into
mainfrom
stage-c/218-records-and-codemod

Conversation

@hyperpolymath
Copy link
Copy Markdown
Owner

No description provided.

hyperpolymath and others added 2 commits May 18, 2026 16:42
Structurally removes the block-vs-record-literal ambiguity (#215
families C+D) with no lookahead heuristic, per the owner-approved
Rust-like model:

  - `{` in expression position is ALWAYS a block.
  - record/struct literals use `#{ … }` (anonymous `#{ x: 1 }` and
    typed `Foo #{ x: 1 }`).
  - record *patterns* unchanged (pattern position has no block
    alternative — no ambiguity there).

Changes: HASH_LBRACE token (token.ml), `#{` lexer rule (lexer.ml;
`#` was previously unused so longest-match is collision-free), both
ExprRecord productions rerouted LBRACE -> HASH_LBRACE (parser.mly).

Menhir conflicts on origin/main (a45b021): 72 S/R + 10 R/R
                                  after:  68 S/R +  7 R/R   (-4 / -3)
Build clean. BREAKING: legacy `{ … }` record syntax no longer parses;
the codemod-migrated repo `.affine` files land in the same PR so the
253/257 gate stays green.

Refs #218 #215

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mechanical companion to the `#{` grammar change — 45 in-repo `.affine`
files (stdlib, tests, golden oracles, e2e fixtures, examples) rewritten
from legacy `{ … }` record literals to `#{ … }`.

Method: a sound, convergent codemod that depends ONLY on the new,
unambiguous grammar (never the old ambiguous parser): parse with the
new grammar, and at each parse error insert `#` before the innermost
enclosing record `{`, iterating to a fixed point. Codepoint-correct
(handles non-ASCII). The codemod tooling is intentionally not committed.

Result: `dune runtest` = 257/257 green (the #218 gate), identical to
the pre-change baseline — no regression; `#{` is now the record syntax
across the full test suite.

Out of scope (tracked, per the #218 plan steps 3–4):
  - estate-wide `.affine` sweep in other repos;
  - ~24 non-gating files the convergent codemod did not auto-migrate
    (LR error reported past the record's `}`): conformance/valid/*,
    docs/guides/warmup/*, codegen-deno/*, some tests/types/* — plus the
    intentional conformance/invalid/* error fixtures and face-syntax
    examples which must stay as-is. None are in the 257 gate.

Refs #218 #215

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hyperpolymath
Copy link
Copy Markdown
Owner Author

Closing as superseded by already-merged work.

Why

Issue #218 (Rust-like record syntax migration {#{) was already resolved on 2026-05-18 — two days before this PR was opened (2026-05-20) — via:

Issue #218 itself is CLOSED with reason COMPLETED (closed 2026-05-18T20:30:10Z).

Evidence

origin/main:lib/parser.mly already contains:

  • %token HASH_LBRACE (line 69)
  • Point #{ x: v, y: w } struct-literal production (line 828)
  • #{ f: v, ..spread } anonymous-record production (line 849)

This PR's parser/lexer changes are byte-equivalent (modulo #218 vs affinescript#215 annotation) to what's already on main. The 49-file .affine migration sweep here was also performed in #222.

Relationship to PR #312

PR #312 is the sibling tooling PR (instrumented parser + codemod) used to generate this migration sweep. Its own body says "do NOT merge into main". Both PRs are now obsolete artefacts from the pre-merge tooling pipeline.

Action

Closing without merge. Stale duplicate of #222 + #223.

🤖 Generated with Claude Code

@hyperpolymath
Copy link
Copy Markdown
Owner Author

Closing-rationale (since the close was already in flight when I went to close-with-comment):

This PR migrates expression-position record literals from { ... } to #{ ... } across stdlib/tests/examples/golden — exactly the migration that already landed on main via #222 (merged 2026-05-18), per the #218 epic. Spot-checked diff: every -/+ pair here is the same kind of mechanical {#{ rewrite that the convergent codemod used in #222 already performed.

Companion PR #312 (the codemod tooling) was also closed as superseded — its body explicitly says "do NOT merge into main".

dune test on origin/main is 257/257 (the #218 gate).

@hyperpolymath hyperpolymath deleted the stage-c/218-records-and-codemod branch May 20, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant