Skip to content

Commit 4200884

Browse files
committed
Fix paren depth filter error
1 parent 19993a1 commit 4200884

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,4 +395,9 @@ FodyWeavers.xsd
395395
*.msp
396396

397397
# JetBrains Rider
398-
*.sln.iml
398+
*.sln.iml
399+
400+
# Claude AI assistant files
401+
.claude/
402+
claude.md
403+
**/claude-tasks.md

src/Hyperbee.Json/Path/Filters/Parser/FilterParser.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,22 @@ private static void MoveNextOperator( ref ParserState state ) // move to the nex
154154
if ( state.Operator.IsLogical() || state.Operator.IsComparison() || state.Operator.IsMath() )
155155
return;
156156

157-
if ( !state.IsParsing )
157+
// Determine if we should stop looking for an operator.
158+
//
159+
// When IsParsing is false (Previous == TerminalCharacter), we've hit a potential stopping point.
160+
// However, ')' as a terminal character is ambiguous - it could be:
161+
// 1. A function's closing paren: `length(@.x)` - should continue to find `> 10` in `(length(@.x) > 10)`
162+
// 2. The outer expression's closing paren - should stop
163+
// 3. A function argument's closing paren - should stop
164+
//
165+
// We return early (stop) when:
166+
// - TerminalCharacter is not ')' (e.g., ',' is unambiguous), OR
167+
// - ParenDepth == 0 (we're at the outermost level, so ')' closes the expression), OR
168+
// - IsArgument is true (we're parsing a function argument, so ')' is definitely ours)
169+
//
170+
// Otherwise, we fall through to the while loop to continue scanning for operators.
171+
172+
if ( !state.IsParsing && (state.TerminalCharacter != ArgClose || state.ParenDepth == 0 || state.IsArgument) )
158173
{
159174
state.Operator = Operator.NonOperator;
160175
return;

0 commit comments

Comments
 (0)