Skip to content

Commit 026b157

Browse files
cursoragentsimbo1905
andcommitted
Issue #128 Fix unsupported recursive descent targets to match interpreter
Addresses review comment: For unsupported recursive descent targets like $..[0:2], $..[?(@.x)], or $..['a','b'], the compiled code was incorrectly adding the current node to results. The interpreter logs and returns no matches for these cases. Changed to generate a no-op comment instead of adding to results, which matches the interpreter's semantics. Co-authored-by: simbo1905 <simbo1905@60hertz.com>
1 parent cbdd23b commit 026b157

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathCompiler.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,10 @@ private static void generateRecursiveDescentInline(
318318
sb.append(" }\n");
319319
}
320320
default -> {
321-
// Unsupported target - add results of current
322-
sb.append(" // Unsupported recursive descent target - adding current\n");
323-
sb.append(" %s.add(%s);\n".formatted(resultsVar, currentVar));
321+
// Unsupported recursive descent target - no-op to match interpreter behavior
322+
// The interpreter logs and returns no matches for unsupported targets like
323+
// $..[0:2], $..[?(@.x)], or $..['a','b']
324+
sb.append(" // Unsupported recursive descent target (no matches per interpreter semantics)\n");
324325
}
325326
}
326327
}

0 commit comments

Comments
 (0)