Skip to content

Drop dead token constructors and add a parse-render round-trip test - #607

Closed
davesnx wants to merge 2 commits into
grammar-clamp-envfrom
parser-dead-tokens-roundtrip
Closed

davesnx wants to merge 2 commits into
grammar-clamp-envfrom
parser-dead-tokens-roundtrip

Conversation

@davesnx

@davesnx davesnx commented Sep 19, 2026

Copy link
Copy Markdown
Owner

Two parser housekeeping items from the quality audit. Tokens.re loses three constructors nothing ever built (TYPE_SELECTOR, AT_KEYWORD, DESCENDANT_COMBINATOR), leftovers from before the lexer unification. And packages/parser/test gains the round-trip regression check it never had: for each CSS body, render(parse(css)) must equal render(parse(render(parse(css)))), and the re-parsed AST must equal the first parse modulo locations and the incidental whitespace tokens the renderer strips.

The corpus is 48 bodies: 30 copied from the css-support cram fixtures plus 18 edge cases (@supports, @container, calc(), var(), url(), :is()/:where()/:not()/:has(), attribute selectors, ::before, .5/-.5/1e3, escaped strings, comments). All 48 pass both checks. One real divergence is pinned as an explicit known-divergence test rather than hidden: an unquoted url(foo.png) parses to the dedicated Ast.Uri node, but the renderer always emits a quoted argument and the quoted form re-parses as a generic Function("url", …), so Ast.Uri never survives a render pass. Text output is unaffected; the AST shape is. Candidate defect for a follow-up.

Evidence at 8500fab:

  • opam exec -- dune build --root . @test-parser: 334 tests, 99 of them the new Roundtrip_test module (48 render-stability, 48 AST-stability, 1 pinned divergence, 2 render-only).
  • make format-check, make build, make test: all exit 0.

Risk: two-way door. Deletion of unused constructors and test-only code; no output changes.

@vercel

vercel Bot commented Sep 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
styled-ppx Ignored Ignored Preview Sep 23, 2026 6:40am UTC

Request Review

@davesnx
davesnx force-pushed the parser-dead-tokens-roundtrip branch 2 times, most recently from df0f4b6 to f91c225 Compare September 22, 2026 13:32
@davesnx
davesnx force-pushed the parser-dead-tokens-roundtrip branch from f91c225 to 09a631a Compare September 23, 2026 06:11
@davesnx
davesnx force-pushed the parser-dead-tokens-roundtrip branch from 09a631a to f75110b Compare September 23, 2026 06:39
@davesnx davesnx closed this Sep 23, 2026
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