davsclaus opened a new pull request, #26822:
URL: https://github.com/apache/camel/pull/26822
Simple has no boolean `!` prefix, and a negated function failed with a
message that points at the operator rather than at the `!`:
```
${body != null && !${body.isEmpty()}}
-> Logical operator && needs a predicate on the right hand side, e.g.
${header.foo} == 'bar'; was: !${body.isEmpty()}
```
**The nesting is not the problem** — I checked each shape against the
runtime before writing the fix:
| expression | result |
|---|---|
| `${body != null && ${body.isEmpty()}}` | evaluates — nesting is fine |
| `${body != null && !${body.isEmpty()}}` | fails |
| `${body != null && !body.isEmpty()}` | fails too, un-nested |
| `${body != null && ${body.isEmpty()} == false}` | evaluates |
| `${body != null && body.isEmpty() == false}` | evaluates |
So the `!` is the cause, and the message now names it and the comparison to
write:
```
! does not negate a function: compare it instead, so !${body.isEmpty()} is
written as
${body.isEmpty()} == false, or negate the operator (!=, !contains)
```
A negated operator is left alone — `${body} !contains 'x'` is unaffected,
and the test asserts it.
### Where it comes from
The local-model benchmark: across 1586 route files a model wrote, this shape
appears in three separate series. A person coming from Java or JavaScript
writes it too.
### Testing
`SimpleSyntaxHintsTest` gains `testNegatedFunction` covering the nested and
un-nested forms and the negated-operator case, with a `functionError` helper
for functions that only fail when the node builds its expression (operators
inside `${ }`, CAMEL-24921) — the existing parser helpers accept those as a
single token. 25 tests in that class and 601 `Simple*` tests in camel-core pass.
Follow-up: CAMEL-24984 proposes supporting `!` as a real negation prefix. If
that lands, this message needs revisiting.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Bp3538HRBPMQkb5ta9xRaj
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]