Repository navigation
Conversation
RobinMalfait
force-pushed
the
fix/brace-expansion-unbalanced-nested
branch
from
November 25, 2026 15:24
7c75b42 to
603f02b
Compare
Contributor
|
I rebased this PR on the latest Sent by an AI assistant on behalf of @RobinMalfait. |
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
In
packages/tailwindcss/src/utils/brace-expansion.ts,expand()initializesendIndextorest.lastIndexOf('}')before scanning for the matching closing brace atdepth === 0:When an outer brace is unclosed while a nested brace is closed (e.g.
a{b,{c}), the loop ends withdepth > 0without finding a matching}, butendIndexretains the index of the inner}instead of-1. As a result,expand()misses the unbalanced outer group and recurses into the sliced inner content, throwing a truncated error (The pattern \{c` is not balanced.) instead of reporting the unbalanced pattern (The pattern `a{b,{c}` is not balanced.`).Fix
endIndex = -1(which also avoids an extralastIndexOf('}')scan on every call) soendIndex === -1reliably detects when no matching closing brace exists.packages/tailwindcss/src/utils/brace-expansion.test.ts.Verification
.\node_modules\.bin\vitest.cmd run packages/tailwindcss/src/utils/brace-expansion.test.ts(22/22 passing; fails before fix)