Skip to content

Match a literal ] straight after a glob class [patch] - #177

Open
matt-edmondson wants to merge 2 commits into
mainfrom
fix/172-literal-bracket-after-glob-class
Open

matt-edmondson wants to merge 2 commits into
mainfrom
fix/172-literal-bracket-after-glob-class

Conversation

@matt-edmondson

@matt-edmondson matt-edmondson commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

DotNet.Glob reads a ] that directly follows a closed bracket class as another member of that class. So *[[][0-9]] matched items[3 but not items[3], and the excluded form -*[[][0-9]] kept the item it was meant to hide.

ExpandGlobClasses already closes the class at the right ]. It now also writes each ] that comes straight after a class as the one-member class []], and DotNet.Glob reads that as a literal ]. Patterns with something else between the class and the ] (*[[]DEBUG]*) are unchanged.

Tests

  • GlobClassFollowedByALiteralBracketMatchesTheBracket covers every row of the issue's table, plus [a]]] and the unaffected *[[]DEBUG]* shape, under both case sensitivities.
  • FilterWithAClassFollowedByALiteralBracketKeepsAndExcludesTheRightItems covers the Filter case and the excluded-token case.
  • ExpandGlobClassesWritesALiteralBracketAfterAClassAsItsOwnClass pins the rewrite.
  • With the fix reverted, all the new cases except the DEBUG control row fail. With it, the full suite passes (224/224).

Overlap: open PRs #165 (unclosed [) and #158 (^ negation) edit the same area. The source change doesn't touch their lines, and the tests sit apart from the lines theirs add. Checked locally: this branch merges cleanly with every other open branch in the repo.

Fixes #172

🤖 Generated with Claude Code

https://claude.ai/code/session_017vfJW5LUHQ94WSDTYRpSJV

DotNet.Glob read a "]" that directly follows a closed bracket class as
another member of that class, so "*[[][0-9]]" matched "items[3" and not
"items[3]", and the excluded form let through what it was written to hide.
ExpandGlobClasses now writes each such "]" as the one-member class "[]]",
which DotNet.Glob reads as the literal the pattern means.

Fixes #172

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW5LUHQ94WSDTYRpSJV
@sonarqubecloud

sonarqubecloud Bot commented Nov 1, 2026

Copy link
Copy Markdown

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.

Glob class followed by a literal ] swallows it: *[[][0-9]] matches "items[3" but not "items[3]"

2 participants