fix(grammar): accept a trailing escaped paren as a value ident in every dialect - #178
Merged
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ry dialect
`color: \(` (and `a\(`) is an escaped code point — a value identifier
whose text ends in `(` — not a function opener. The value ident/function
dispatch routed on `endsWith('(')`, which cannot tell an escaped `\(`
from a structural `(`, so all four dialects wrongly demanded a `)` and
rejected valid CSS.
Fix with proper dispatch ordering, not a new matcher: each grammar's
value dispatch takes a more-specific `when(endsWith('\\('), <keyword arm>)`
before the generic `when(endsWith('('), <call>)`. `foo(`, `\41(`, `url(`,
`calc(` still route to their function/call arms; `\(` and `a\(` route to
the keyword arm and emit byte-identical output across all four dialects.
The only blind spot is `\\(` — an escaped backslash then a real paren, a
function literally named `\` — which is not valid CSS and has no
reachable input; a comment records it.
Closes the trailing-`\(` carve-out on ledger G36 (now SETTLED). Pins the
escaped-value story (`\;` and `\(`) in test/css-superset-corpus.ts across
all four dialect gates. No parseman change.
matthew-dean
force-pushed
the
fix/escaped-trailing-paren-dispatch
branch
from
September 8, 2026 13:30
4e65f75 to
d19c229
Compare
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.
Problem
color: \((anda\() is valid CSS — an escaped code point, i.e. a value identifier whose text happens to end in(— but all four dialects rejected it:color: \(color: a\(color: foo()/\41()/url(...)/calc(...)The value ident/function dispatch routed on
endsWith('('), which can't tell an escaped\(from a structural(, so the token\(was misread as a function opener and the parser demanded a). (This is the trailing-\(carve-out left open on ledger G36 by #163.)Fix — proper dispatch, no new matcher
Each grammar's value dispatch takes a more-specific arm before the generic one:
Dispatch picks the first matching arm, so the escaped-paren suffix wins. It's a plain-string
endsWithon the fast path — no regex, no parseman change. Applied to the value ident/function dispatch in all four grammars (css has two ladders — typed and non-typed — kept in sync). Pseudo/query/header dispatches are not value-reachable and are untouched.The one blind spot is
\\(— an escaped backslash then a real paren, a function literally named\— which isn't valid CSS and has no reachable input; a comment records it.Verification
\(/a\(;foo()/\41()/url()/calc()still route to their function arms. Output is byte-identical across all four (color: \(→color: \(, Keyword preserved).test/css-superset-corpus.ts('escaped paren in a value identifier', 'escaped delimiter in a value identifier') across all four dialect gates; acceptance matrix 6/6; less golden green.\(carve-out (now SETTLED).Follow-up to #163; no parseman dependency change.