fix: keep the original error attribution for and/or operands
To allow short-circuiting, the RHS of `and`/`or` is evaluated lazily inside evaluateBooleanExpression, so it runs inside the try block of evaluateBinary. Every error raised while evaluating that operand was then stamped with the operator's own token and position, hiding what actually failed: 1=1 and $contains([''], '') // Argument 1 of function "and" does not match function signature The same expression inside a user-defined function reports "contains" correctly, because there the operand is evaluated at the call site. The other binary operators are unaffected: they evaluate the RHS before the try block, so `1 + $contains([''], '')` already reports "contains". Only claim the error for the operator when nothing else has attributed it yet, which is the same guard already used when applying a procedure. fn.boolean cannot throw, so an error reaching this catch always comes from the operand. Errors that carry no token (a duplicate group key, for example) are still reported against the operator exactly as before. Fixes #765
This commit is contained in:
1 parent
71e11d602e
commit
deaab007e1
5 files changed
+112
-3
No files matched your search
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"description": "error on the right of and is reported against the failing function, not the operator",
|
||||
"expr": "(1=1 and $contains([''], ''))",
|
||||
"dataset": null,
|
||||
"bindings": {},
|
||||
"error": {
|
||||
"code": "T0410",
|
||||
"token": "contains"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user