diff --git a/src/path/parse.ts b/src/path/parse.ts index 6b76d79..8635513 100644 --- a/src/path/parse.ts +++ b/src/path/parse.ts @@ -3,6 +3,7 @@ import { JSONPathSyntaxError, JSONPathTypeError } from "./errors"; import { BooleanLiteral, FilterExpression, + FilterExpressionLiteral, FunctionExtension, InfixExpression, LogicalExpression, @@ -330,6 +331,14 @@ export class Parser { ); } } + + if (expr instanceof FilterExpressionLiteral) { + throw new JSONPathSyntaxError( + "filter expression literals must be compared", + expr.token, + ); + } + return keys ? new KeysFilterSelector( this.environment, @@ -387,7 +396,21 @@ export class Parser { if (COMPARISON_OPERATORS.has(operator)) { this.throwForNonComparable(left); this.throwForNonComparable(right); + } else { + if (left instanceof FilterExpressionLiteral) { + throw new JSONPathSyntaxError( + "filter expression literals must be compared", + left.token, + ); + } + if (right instanceof FilterExpressionLiteral) { + throw new JSONPathSyntaxError( + "filter expression literals must be compared", + right.token, + ); + } } + return new InfixExpression(tok, left, operator, right); } diff --git a/tests/path/cts b/tests/path/cts index a4b176f..a4868b0 160000 --- a/tests/path/cts +++ b/tests/path/cts @@ -1 +1 @@ -Subproject commit a4b176f7131a8be38aea8286e603830f33d916c1 +Subproject commit a4868b05545407472fa9bbdfb6796c3f10143189